You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2020/06/23 02:16:01 UTC

[GitHub] [arrow] mrkn commented on a change in pull request #7477: ARROW-4221: [C++][Python] Add canonical flag in COO sparse index

mrkn commented on a change in pull request #7477:
URL: https://github.com/apache/arrow/pull/7477#discussion_r443922882



##########
File path: python/pyarrow/tensor.pxi
##########
@@ -199,7 +202,13 @@ shape: {0.shape}""".format(self)
             for x in dim_names:
                 c_dim_names.push_back(tobytes(x))
 
-        coords = np.vstack([obj.row, obj.col]).T
+        row = obj.row
+        col = obj.col
+        if obj.has_canonical_format:
+            order = np.lexsort((col, row))  # row-major order

Review comment:
       SciPy's coo_matrix employs column-major order, but our SparseCOOIndex employs row-major order.
   This is the reason why we need to sort the index here.
   
   The reason why our SparseCOOIndex should employ row-major order is that TensorFlow's SparseTensor employs row-major order.  Converting from SciPy's coo_matrrix needs to copy the index matrix even if we employ column-major order, but converting from TensorFlow's SparseTensor does not need to copy the index matrix if we employ row-major order.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org