Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix transient bug in test with array_equal of empty arrays #1374

Merged
merged 3 commits into from
Sep 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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