title: Is there a way to form sparse n-dimensional array in Python3?
body: <p>I am pretty new to Python and have been wondering if there an easy way so that I could form a sparse n-dimensional array M in Python3 with following 2 conditions mainly required (along the lines of SciPy COO_Matrix):</p>
  
  <ol>
  <li>M[dim1,dim2,dim3,...] = 1.0</li>
  <li>Like SciPy COO_Matrix M: M.row, M.col, I may be able to get all the row and column indices for which non-zero entries exist in the matrix. In N-dimension, this generalizes to calling: M.1 for 1st dimension, M.2 for 2nd dimension and so on...</li>
  </ol>
  
  <p>For 2-dimension (the 2 conditions):</p>
  
  <pre><code> 1.
       for u, i in data:
          mat[u, i] = 1.0
  
   2. def get_triplets(mat):
          return mat.row, mat.col
  </code></pre>
  
  <p>Can these 2 conditions be generalized in N-dimensions? I searched and came across this:</p>
  
  <p><a href="https://stackoverflow.com/questions/7685128/sparse-3d-matrix-array-in-python">sparse 3d matrix/array in Python?</a>  </p>
  
  <p>But here 2nd condition is not satisfied: In other words, I can't get the all the nth dimensional indices in a vectorized format.</p>
  
  <p>Also this:
  <a href="http://www.janeriksolem.net/sparray-sparse-n-dimensional-arrays-in.html" rel="nofollow noreferrer">http://www.janeriksolem.net/sparray-sparse-n-dimensional-arrays-in.html</a> works for python and not python3.</p>
  
  <p>Is there a way to implement n-dimensional arrays with above mentioned 2 conditions satisfied? Or I am over-complicating things? I appreciate any help with this :)</p>