rok commented on code in PR #50907:
URL: https://github.com/apache/arrow/pull/50907#discussion_r3854230310


##########
python/pyarrow/tests/test_sparse_tensor.py:
##########
@@ -254,6 +257,27 @@ def test_sparse_csr_matrix_from_dense(dtype_str, 
arrow_type):
     assert np.array_equal(indices, result_indices)
 
 
[email protected](not csr_array, reason="requires scipy")
[email protected]('pa_class,sc_array_class', [
+    pytest.param(
+        pa.SparseCSRMatrix, csr_array, id='CSR'
+    ),
+    pytest.param(
+        pa.SparseCSCMatrix, csc_array, id='CSC'
+    ),
+])
+def test_sparse_csx_matrix_from_1d(pa_class, sc_array_class):
+    array = np.array([1, 0, 2, 0, 0, 3, 0, 4], dtype=np.int64)
+    tensor = pa.Tensor.from_numpy(array)
+
+    scipy_array = sc_array_class(array.reshape(1, -1))

Review Comment:
   I see. This is annoying - so:
   ```python
   >>> scipy.sparse.csc_array([1, 0, 2, 0, 0, 3]).ndim
   ValueError: CSC arrays don't support 1D input. Use 2D
   
   >>> scipy.sparse.csc_matrix([1, 0, 2, 0, 0, 3]).ndim
   2
   ```
   
   `csc_matrix` accepts 1D input while `csc_array` array does not.
   
   Let's then simply test that 1D `csc_matrix`/`csr_matrix`roundtrips PyArrow 
tensor and that PyArrow tensor roundtrips to `csc_matrix`/`csr_matrix`. Forbid 
reshape path in case we have another type of object.



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

Reply via email to