MCPcopy Create free account
hub / github.com/apache/arrow / test_sparse_tensor_equals

Function test_sparse_tensor_equals

python/pyarrow/tests/test_sparse_tensor.py:168–188  ·  view source on GitHub ↗
(sparse_tensor_type)

Source from the content-addressed store, hash-verified

166 pa.SparseCSFTensor,
167])
168def test_sparse_tensor_equals(sparse_tensor_type):
169 def eq(a, b):
170 assert a.equals(b)
171 assert a == b
172 assert not (a != b)
173
174 def ne(a, b):
175 assert not a.equals(b)
176 assert not (a == b)
177 assert a != b
178
179 data = np.random.randn(10, 6)[::, ::2]
180 sparse_tensor1 = sparse_tensor_type.from_dense_numpy(data)
181 sparse_tensor2 = sparse_tensor_type.from_dense_numpy(
182 np.ascontiguousarray(data))
183 eq(sparse_tensor1, sparse_tensor2)
184 data = data.copy()
185 data[9, 0] = 1.0
186 sparse_tensor2 = sparse_tensor_type.from_dense_numpy(
187 np.ascontiguousarray(data))
188 ne(sparse_tensor1, sparse_tensor2)
189
190
191@pytest.mark.parametrize('dtype_str,arrow_type', tensor_type_pairs)

Callers

nothing calls this directly

Calls 3

copyMethod · 0.80
eqFunction · 0.70
neFunction · 0.70

Tested by

no test coverage detected