parameters: (A,blocksize)
docstring: For a given blocksize=(r,c) count the number of occupied
      blocks in a sparse matrix A
docstring_summary: For a given blocksize=(r,c) count the number of occupied
      blocks in a sparse matrix A
docstring_tokens: For a given blocksize = ( r c ) count the number of occupied blocks in a sparse matrix A
function: def count_blocks(A,blocksize):
      """For a given blocksize=(r,c) count the number of occupied
      blocks in a sparse matrix A
      """
      r,c = blocksize
      if r < 1 or c < 1:
          raise ValueError('r and c must be positive')
  
      if isspmatrix_csr(A):
          M,N = A.shape
          return csr_count_blocks(M,N,r,c,A.indptr,A.indices)
      elif isspmatrix_csc(A):
          return count_blocks(A.T,(c,r))
      else:
          return count_blocks(csr_matrix(A),blocksize)
function_tokens: def count_blocks ( A , blocksize ) : r , c = blocksize if r < 1 or c < 1 : raise ValueError ( 'r and c must be positive' ) if isspmatrix_csr ( A ) : M , N = A . shape return csr_count_blocks ( M , N , r , c , A . indptr , A . indices ) elif isspmatrix_csc ( A ) : return count_blocks ( A . T , ( c , r ) ) else : return count_blocks ( csr_matrix ( A ) , blocksize )