@@ -176,20 +176,18 @@ def test_add(rng, dtype):
176176 assert isinstance (actual , np .ndarray )
177177 np .testing .assert_array_equal (actual , expected )
178178
179- # NOTE: Fixed in https://github.com/llvm/llvm-project/pull/108615
180- # actual = sparse.add(c_tensor, c_tensor).to_scipy_sparse()
181- # expected = c + c
182- # assert isinstance(actual, np.ndarray)
183- # np.testing.assert_array_equal(actual, expected)
179+ actual = sparse .to_numpy (sparse .add (dense_tensor , dense_tensor ))
180+ expected = dense + dense
181+ assert isinstance (actual , np .ndarray )
182+ np .testing .assert_array_equal (actual , expected )
184183
185184 actual = sparse .to_scipy (sparse .add (csr_2_tensor , coo_tensor ))
186185 expected = csr_2 + coo
187186 assert_csx_equal (expected , actual )
188187
189- # NOTE: https://discourse.llvm.org/t/passmanager-fails-on-simple-coo-addition-example/81247
190- # actual = sparse.add(d_tensor, d_tensor).to_scipy_sparse()
191- # expected = d + d
192- # np.testing.assert_array_equal(actual.todense(), expected.todense())
188+ actual = sparse .to_scipy (sparse .add (coo_tensor , coo_tensor ))
189+ expected = coo + coo
190+ np .testing .assert_array_equal (actual .todense (), expected .todense ())
193191
194192
195193@parametrize_dtypes
@@ -226,8 +224,11 @@ def test_coo_3d_format(dtype):
226224 format = sparse .levels .get_storage_format (
227225 levels = (
228226 sparse .levels .Level (sparse .levels .LevelFormat .Compressed , sparse .levels .LevelProperties .NonUnique ),
229- sparse .levels .Level (sparse .levels .LevelFormat .Singleton , sparse .levels .LevelProperties .NonUnique ),
230- sparse .levels .Level (sparse .levels .LevelFormat .Singleton , sparse .levels .LevelProperties (0 )),
227+ sparse .levels .Level (
228+ sparse .levels .LevelFormat .Singleton ,
229+ sparse .levels .LevelProperties .NonUnique | sparse .levels .LevelProperties .SOA ,
230+ ),
231+ sparse .levels .Level (sparse .levels .LevelFormat .Singleton , sparse .levels .LevelProperties .SOA ),
231232 ),
232233 order = "C" ,
233234 pos_width = 64 ,
@@ -237,20 +238,19 @@ def test_coo_3d_format(dtype):
237238
238239 SHAPE = (2 , 2 , 4 )
239240 pos = np .array ([0 , 7 ])
240- crd = np .array ([[ 0 , 1 , 0 , 0 , 1 , 1 , 0 ], [1 , 3 , 1 , 0 , 0 , 1 , 0 ], [3 , 1 , 1 , 0 , 1 , 1 , 1 ]])
241+ crd = [ np .array ([0 , 1 , 0 , 0 , 1 , 1 , 0 ]), np . array ( [1 , 3 , 1 , 0 , 0 , 1 , 0 ]), np . array ( [3 , 1 , 1 , 0 , 1 , 1 , 1 ])]
241242 data = np .array ([1 , 2 , 3 , 4 , 5 , 6 , 7 ], dtype = dtype )
242- carrs = (pos , crd , data )
243+ carrs = (pos , * crd , data )
243244
244245 coo_array = sparse .from_constituent_arrays (format = format , arrays = carrs , shape = SHAPE )
245246 result = coo_array .get_constituent_arrays ()
246247 for actual , expected in zip (result , carrs , strict = True ):
247248 np .testing .assert_array_equal (actual , expected )
248249
249- # NOTE: Blocked by https://github.com/llvm/llvm-project/pull/109135
250- # res_arrays = sparse.add(coo_array, coo_array).get_constituent_arrays()
251- # res_expected = (pos, crd, data * 2)
252- # for actual, expected in zip(res_arrays, res_expected, strict=False):
253- # np.testing.assert_array_equal(actual, expected)
250+ result_arrays = sparse .add (coo_array , coo_array ).get_constituent_arrays ()
251+ constituent_arrays = (pos , * crd , data * 2 )
252+ for actual , expected in zip (result_arrays , constituent_arrays , strict = False ):
253+ np .testing .assert_array_equal (actual , expected )
254254
255255
256256@parametrize_dtypes
0 commit comments