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/07/10 03:40:16 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_r452605554



##########
File path: python/pyarrow/tensor.pxi
##########
@@ -270,8 +279,10 @@ shape: {0.shape}""".format(self)
                                               &out_data, &out_coords))
         data = PyObject_to_object(out_data)
         coords = PyObject_to_object(out_coords)
-        result = coo_matrix((data[:, 0], (coords[:, 0], coords[:, 1])),
-                            shape=self.shape)
+        row, col = coords[:, 0], coords[:, 1]
+        result = coo_matrix((data[:, 0], (row, col)), shape=self.shape)
+        if self.has_canonical_format:
+            result.sum_duplicates()

Review comment:
       @rok Yes, if `is_canonical` is true, the indices matrix is sorted in row-major order and doesn't have duplicates.
   In other words, this flag has the same meaning as `has_canonical_format` of `scipy.sparse.coo_matrix` but the order is row-major, instead of column-major.




----------------------------------------------------------------
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