title: How to check if a SciPy CSR matrix is empty (i.e. contains only zeroes)?
body: <p>What is the canonical way to check if a <a href="http://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csr_matrix.html" rel="noreferrer">SciPy CSR matrix</a> is empty (i.e. contains only zeroes)?</p>
  
  <p>I use <code>nonzero()</code>:</p>
  
  <pre><code>def is_csr_matrix_only_zeroes(my_csr_matrix):
      return(len(my_csr_matrix.nonzero()[0]) == 0)
  
  from scipy.sparse import csr_matrix
  print(is_csr_matrix_only_zeroes(csr_matrix([[1,2,0],[0,0,3],[4,0,5]])))
  print(is_csr_matrix_only_zeroes(csr_matrix([[0,0,0],[0,0,0],[0,0,0]])))
  print(is_csr_matrix_only_zeroes(csr_matrix((2,3))))
  print(is_csr_matrix_only_zeroes(csr_matrix([[0,0,0],[0,1,0],[0,0,0]])))
  </code></pre>
  
  <p>outputs</p>
  
  <pre><code>False
  True
  True
  False
  </code></pre>
  
  <p>but I wonder whether there exist more direct or efficient ways.</p>
  
  <p>(Related but different: <a href="https://stackoverflow.com/q/20577372/395857">Check if scipy sparse matrix entry exists</a>)</p>