Skip to content

Commit d99d52d

Browse files
committed
Implementing review feedback.
1 parent 4efdd35 commit d99d52d

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

python/pyarrow/tensor.pxi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ shape: {0.shape}""".format(self)
203203
coords = np.require(coords, dtype='i8', requirements='F')
204204

205205
check_status(NdarraysToSparseCOOTensor(c_default_memory_pool(),
206-
obj.data.view(), coords, c_shape, c_dim_names,
206+
obj.data, coords, c_shape, c_dim_names,
207207
&csparse_tensor))
208208
return pyarrow_wrap_sparse_coo_tensor(csparse_tensor)
209209

@@ -227,10 +227,10 @@ shape: {0.shape}""".format(self)
227227
for x in dim_names:
228228
c_dim_names.push_back(tobytes(x))
229229

230-
coords = np.require(obj.coords.T.view(), dtype='i8', requirements='F')
230+
coords = np.require(obj.coords.T, dtype='i8', requirements='F')
231231

232232
check_status(NdarraysToSparseCOOTensor(c_default_memory_pool(),
233-
obj.data.view(), coords, c_shape, c_dim_names,
233+
obj.data, coords, c_shape, c_dim_names,
234234
&csparse_tensor))
235235
return pyarrow_wrap_sparse_coo_tensor(csparse_tensor)
236236

@@ -286,7 +286,7 @@ shape: {0.shape}""".format(self)
286286
&out_data, &out_coords))
287287
data = PyObject_to_object(out_data)
288288
coords = PyObject_to_object(out_coords)
289-
result = COO(data=data, coords=coords.T, shape=self.shape)
289+
result = COO(data=data[:, 0], coords=coords.T, shape=self.shape)
290290
return result
291291

292292
def to_tensor(self):

python/pyarrow/tests/test_sparse_tensor.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ def test_sparse_csr_matrix_scipy_roundtrip(dtype_str, arrow_type):
336336
@pytest.mark.parametrize('dtype_str,arrow_type', tensor_type_pairs)
337337
def test_pydata_sparse_sparse_coo_tensor_roundtrip(dtype_str, arrow_type):
338338
dtype = np.dtype(dtype_str)
339-
data = np.array([[1, 2, 3, 4, 5, 6]]).T.astype(dtype)
339+
data = np.array([1, 2, 3, 4, 5, 6]).astype(dtype)
340340
coords = np.array([
341341
[0, 0, 2, 3, 1, 3],
342342
[0, 2, 0, 4, 5, 5],
@@ -354,3 +354,5 @@ def test_pydata_sparse_sparse_coo_tensor_roundtrip(dtype_str, arrow_type):
354354
assert sparse_array.dtype == out_sparse_array.dtype
355355
assert np.array_equal(sparse_array.data, out_sparse_array.data)
356356
assert np.array_equal(sparse_array.coords, out_sparse_array.coords)
357+
assert np.array_equal(sparse_array.todense(),
358+
sparse_tensor.to_tensor().to_numpy())

0 commit comments

Comments
 (0)