Skip to content

Commit

Permalink
Fix transient bug in test with array_equal of empty arrays (#1374)
Browse files Browse the repository at this point in the history
  • Loading branch information
tbennun authored Sep 26, 2023
1 parent d0eb400 commit f6263b5
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions tests/numpy/ufunc_support_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ def test_ufunc_add_where():
W = np.random.randint(2, size=(10, ), dtype=np.bool_)
C = ufunc_add_where(A, B, W)
assert (np.array_equal(np.add(A, B, where=W)[W], C[W]))
assert (not np.array_equal((A + B)[np.logical_not(W)], C[np.logical_not(W)]))
if not np.all(W): # If all of W is True, np.logical_not(W) would result in empty arrays
assert (not np.array_equal((A + B)[np.logical_not(W)], C[np.logical_not(W)]))


@dace.program
Expand All @@ -154,18 +155,6 @@ def test_ufunc_add_where_false():
assert (not np.array_equal(A + B, C))


@dace.program
def ufunc_add_where_false(A: dace.int32[10], B: dace.int32[10]):
return np.add(A, B, where=False)


def test_ufunc_add_where_false():
A = np.random.randint(1, 10, size=(10, ), dtype=np.int32)
B = np.random.randint(1, 10, size=(10, ), dtype=np.int32)
C = ufunc_add_where_false(A, B)
assert (not np.array_equal(A + B, C))


@dace.program
def ufunc_add_where_list(A: dace.int32[2], B: dace.int32[2]):
return np.add(A, B, where=[True, False])
Expand Down Expand Up @@ -456,7 +445,7 @@ def test_ufunc_add_outer_where():
B = np.random.randint(1, 10, size=(2, 2, 2, 2, 2), dtype=np.int32)
W = np.random.randint(2, size=(2, 2, 2, 2, 2, 2, 2, 2, 2, 2), dtype=np.bool_)
s = ufunc_add_outer_where(A, B, W)
assert (np.array_equal(np.add.outer(A, B, where=W)[W], s[W]))
assert np.array_equal(np.add.outer(A, B, where=W)[W], s[W])


@dace.program
Expand All @@ -472,7 +461,7 @@ def test_ufunc_add_outer_where2():
C = ufunc_add_outer_where2(A, B, W)
where = np.empty((2, 2, 2, 2, 2, 2, 2, 2, 2, 2), dtype=np.bool_)
where[:] = W
assert (np.array_equal(np.add.outer(A, B, where=W)[where], C[where]))
assert np.array_equal(np.add.outer(A, B, where=W)[where], C[where])


@compare_numpy_output()
Expand Down

0 comments on commit f6263b5

Please sign in to comment.