mrkn commented on a change in pull request #7477: URL: https://github.com/apache/arrow/pull/7477#discussion_r452834004
########## 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: The `self` here is not an instance of `scipy.sparse.coo_matrix`, but it is a `SparseCOOTensor`. So `self.has_canonical_format == True` means the index of the `SparseCOOTensor`, that is `(row, col)` pair, is sorted in row-major order. Then `result.sum_duplicates` do sort `(row, col)` in column-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: us...@infra.apache.org