rok commented on code in PR #50907:
URL: https://github.com/apache/arrow/pull/50907#discussion_r3846096665
##########
python/pyarrow/tests/test_sparse_tensor.py:
##########
@@ -254,6 +258,28 @@ def test_sparse_csr_matrix_from_dense(dtype_str,
arrow_type):
assert np.array_equal(indices, result_indices)
[email protected]('pa_class,sc_class', [
+ pytest.param(pa.SparseCSRMatrix, csr_matrix, id='CSR'),
+ pytest.param(pa.SparseCSCMatrix, csc_matrix, id='CSC'),
+])
+def test_sparse_csx_matrix_from_1d(pa_class, sc_class):
+ if sc_class is None:
+ pytest.skip('scipy not available')
+
+ array = np.array([1, 0, 2, 0, 0, 3, 0, 4], dtype=np.int64)
+ tensor = pa.Tensor.from_numpy(array)
+
+ sc_sparse = sc_class(array)
+
+ sparse = pa_class.from_dense_numpy(array)
+ assert sparse.shape == sc_sparse.shape
+ assert sparse.non_zero_length == sc_sparse.nnz
+
+ sparse = pa_class.from_tensor(tensor)
+ assert sparse.shape == sc_sparse.shape
+ assert sparse.non_zero_length == sc_sparse.nnz
Review Comment:
Why not compare `sc_sparse` and `sparse` more directly? Also can you rename
`sc_sparse` to `scipy_matrix` and `sparse` to `sparse_tensor` as is the style
elsewhere in this file?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]