8000 BUG: Fix numpy.isin for timedelta dtype by MilesCranmer · Pull Request #21860 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: Fix numpy.isin for timedelta dtype #21860

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

Merged
merged 7 commits into from
Jun 29, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
TST: Add test for mixed boolean/integer in1d
  • Loading branch information
MilesCranmer committed Jun 27, 2022
commit c25f0c74ec6c208e47e8e7a5d2672db4011d7ad4
13 changes: 13 additions & 0 deletions numpy/lib/tests/test_arraysetops.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,19 @@ def test_in1d_table_timedelta_fails(self):
with pytest.raises(ValueError):
in1d(a, b, kind="table")

@pytest.mark.parametrize("kind", [None, "sort", "table"])
def test_in1d_mixed_boolean(self, kind):
"""Test that in1d works as expected for bool/int input."""
for dtype in np.typecodes["AllInteger"]:
a = np.array([True, False, False], dtype=bool)
b = np.array([1, 1, 1, 1], dtype=dtype)
expected = np.array([True, False, False], dtype=bool)
assert_array_equal(in1d(a, b, kind=kind), expected)

a, b = b, a
expected = np.array([True, True, True, True], dtype=bool)
assert_array_equal(in1d(a, b, kind=kind), expected)

def test_in1d_first_array_is_object(self):
ar1 = [None]
ar2 = np.array([1]*10)
Expand Down
0