diff options
author | MilesCranmer <miles.cranmer@gmail.com> | 2022-06-10 14:40:25 -0400 |
---|---|---|
committer | MilesCranmer <miles.cranmer@gmail.com> | 2022-06-10 14:40:25 -0400 |
commit | d1a5309810cc55da8443568d215f1992c7a261cd (patch) | |
tree | 896e299f30b9fe7639372ef508dd8e8dcf3e8856 /numpy/lib/tests | |
parent | 68a1acf41586bb65538af84ce9c74ec5e0872750 (diff) | |
download | numpy-d1a5309810cc55da8443568d215f1992c7a261cd.tar.gz |
MAINT: Update tests to use new `method` argument
Diffstat (limited to 'numpy/lib/tests')
-rw-r--r-- | numpy/lib/tests/test_arraysetops.py | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/numpy/lib/tests/test_arraysetops.py b/numpy/lib/tests/test_arraysetops.py index 60d9b7c87..affd2e2d6 100644 --- a/numpy/lib/tests/test_arraysetops.py +++ b/numpy/lib/tests/test_arraysetops.py @@ -205,7 +205,8 @@ class TestSetOps: isin_slow = np.vectorize(_isin_slow, otypes=[bool], excluded={1}) def assert_isin_equal(a, b, old_algorithm=None): - x = isin(a, b, _slow_integer=old_algorithm) + method = "sort" if old_algorithm else "dictionary" + x = isin(a, b, method=old_algorithm) y = isin_slow(a, b) assert_array_equal(x, y) @@ -257,21 +258,21 @@ class TestSetOps: ec = np.array([True, False, True, True]) c = in1d(a, b, assume_unique=True) assert_array_equal(c, ec) - c = in1d(a, b, assume_unique=True, _slow_integer=True) + c = in1d(a, b, assume_unique=True, method="dictionary") assert_array_equal(c, ec) a[0] = 8 ec = np.array([False, False, True, True]) c = in1d(a, b, assume_unique=True) assert_array_equal(c, ec) - c = in1d(a, b, assume_unique=True, _slow_integer=True) + c = in1d(a, b, assume_unique=True, method="dictionary") assert_array_equal(c, ec) a[0], a[3] = 4, 8 ec = np.array([True, False, True, False]) c = in1d(a, b, assume_unique=True) assert_array_equal(c, ec) - c = in1d(a, b, assume_unique=True, _slow_integer=True) + c = in1d(a, b, assume_unique=True, method="dictionary") assert_array_equal(c, ec) a = np.array([5, 4, 5, 3, 4, 4, 3, 4, 3, 5, 2, 1, 5, 5]) @@ -280,7 +281,7 @@ class TestSetOps: False, True, False, False, False] c = in1d(a, b) assert_array_equal(c, ec) - c = in1d(a, b, _slow_integer=True) + c = in1d(a, b, method="dictionary") assert_array_equal(c, ec) b = b + [5, 5, 4] * mult @@ -288,7 +289,7 @@ class TestSetOps: True, False, True, True] c = in1d(a, b) assert_array_equal(c, ec) - c = in1d(a, b, _slow_integer=True) + c = in1d(a, b, method="dictionary") assert_array_equal(c, ec) a = np.array([5, 7, 1, 2]) @@ -296,7 +297,7 @@ class TestSetOps: ec = np.array([True, False, True, True]) c = in1d(a, b) assert_array_equal(c, ec) - c = in1d(a, b, _slow_integer=True) + c = in1d(a, b, method="dictionary") assert_array_equal(c, ec) a = np.array([5, 7, 1, 1, 2]) @@ -304,7 +305,7 @@ class TestSetOps: ec = np.array([True, False, True, True, True]) c = in1d(a, b) assert_array_equal(c, ec) - c = in1d(a, b, _slow_integer=True) + c = in1d(a, b, method="dictionary") assert_array_equal(c, ec) a = np.array([5, 5]) @@ -312,7 +313,7 @@ class TestSetOps: ec = np.array([False, False]) c = in1d(a, b) assert_array_equal(c, ec) - c = in1d(a, b, _slow_integer=True) + c = in1d(a, b, method="dictionary") assert_array_equal(c, ec) a = np.array([5]) @@ -320,7 +321,7 @@ class TestSetOps: ec = np.array([False]) c = in1d(a, b) assert_array_equal(c, ec) - c = in1d(a, b, _slow_integer=True) + c = in1d(a, b, method="dictionary") assert_array_equal(c, ec) assert_array_equal(in1d([], []), []) @@ -412,7 +413,7 @@ class TestSetOps: b = [2, 3, 4] * mult assert_array_equal(np.invert(in1d(a, b)), in1d(a, b, invert=True)) assert_array_equal(np.invert(in1d(a, b)), - in1d(a, b, invert=True, _slow_integer=True)) + in1d(a, b, invert=True, method="dictionary")) for mult in (1, 10): a = np.array([5, 4, 5, 3, 4, 4, 3, 4, 3, 5, 2, 1, 5, 5], @@ -421,7 +422,7 @@ class TestSetOps: b = np.array(b, dtype=np.float32) assert_array_equal(np.invert(in1d(a, b)), in1d(a, b, invert=True)) assert_array_equal(np.invert(in1d(a, b)), - in1d(a, b, invert=True, _slow_integer=True)) + in1d(a, b, invert=True, method="dictionary")) def test_in1d_ravel(self): # Test that in1d ravels its input arrays. This is not documented @@ -435,21 +436,21 @@ class TestSetOps: assert_array_equal(in1d(a, b, assume_unique=False), ec) assert_array_equal(in1d(a, long_b, assume_unique=True), ec) assert_array_equal(in1d(a, long_b, assume_unique=False), ec) - assert_array_equal(in1d(a, b, assume_unique=True, _slow_integer=True), + assert_array_equal(in1d(a, b, assume_unique=True, method="dictionary"), ec) - assert_array_equal(in1d(a, b, assume_unique=False, _slow_integer=True), + assert_array_equal(in1d(a, b, assume_unique=False, method="dictionary"), ec) assert_array_equal(in1d(a, long_b, assume_unique=True, - _slow_integer=True), + method="dictionary"), ec) assert_array_equal(in1d(a, long_b, assume_unique=False, - _slow_integer=True), + method="dictionary"), ec) def test_in1d_hit_alternate_algorithm(self): """Hit the standard isin code with integers""" # Need extreme range to hit standard code - # This hits it without the use of _slow_integer + # This hits it without the use of method='dictionary' a = np.array([5, 4, 5, 3, 4, 4, 1e9], dtype=np.int64) b = np.array([2, 3, 4, 1e9], dtype=np.int64) expected = np.array([0, 1, 0, 1, 1, 1, 1], dtype=np.bool) @@ -470,11 +471,11 @@ class TestSetOps: assert_array_equal(expected, in1d(a, b)) assert_array_equal(expected, - in1d(a, b, _slow_integer=True)) + in1d(a, b, method="dictionary")) assert_array_equal(np.invert(expected), in1d(a, b, invert=True)) assert_array_equal(np.invert(expected), - in1d(a, b, invert=True, _slow_integer=True)) + in1d(a, b, invert=True, method="dictionary")) def test_in1d_first_array_is_object(self): ar1 = [None] |