title: python - how to check if matrix is sparse or not
body: <p>I have a matrix and I want to check if it is sparse or not.</p>
  
  <p>Things I have tried:</p>
  
  <ol>
  <li><p>isinstance method:</p>
  
  <pre><code>if isinstance(&lt;matrix&gt;, scipy.sparse.csc.csc_matrix):
  </code></pre></li>
  </ol>
  
  <p>This works fine if I know exactly which sparse class I want to check.</p>
  
  <ol start="2">
  <li>getformat method: But it assumes that my matrix is sparse and give format</li>
  </ol>
  
  <p>But I want a way to know if matrix is sparse or not, and should work irrespective of which sparse class.</p>
  
  <p>Kindly help me.</p>