diff options
author | MilesCranmer <miles.cranmer@gmail.com> | 2022-06-10 14:37:59 -0400 |
---|---|---|
committer | MilesCranmer <miles.cranmer@gmail.com> | 2022-06-10 14:37:59 -0400 |
commit | 68a1acf41586bb65538af84ce9c74ec5e0872750 (patch) | |
tree | 0f0fde659a51b4fb20cddd2e4c349f1dfb6667f4 /numpy/lib/arraysetops.py | |
parent | f570065dac7bae4b6841224f7ee6b68f08754edd (diff) | |
download | numpy-68a1acf41586bb65538af84ce9c74ec5e0872750.tar.gz |
Add check for methods
Diffstat (limited to 'numpy/lib/arraysetops.py')
-rw-r--r-- | numpy/lib/arraysetops.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/numpy/lib/arraysetops.py b/numpy/lib/arraysetops.py index 4ef2468d5..6320ea1a5 100644 --- a/numpy/lib/arraysetops.py +++ b/numpy/lib/arraysetops.py @@ -616,6 +616,11 @@ def in1d(ar1, ar2, assume_unique=False, invert=False, method='auto'): integer_arrays = (np.issubdtype(ar1.dtype, np.integer) and np.issubdtype(ar2.dtype, np.integer)) + if method not in ['auto', 'sort', 'dictionary']: + raise ValueError( + "Invalid method: {0}. ".format(method) + + "Please use 'auto', 'sort' or 'dictionary'.") + if integer_arrays and method in ['auto', 'dictionary']: ar2_min = np.min(ar2) ar2_max = np.max(ar2) @@ -659,6 +664,11 @@ def in1d(ar1, ar2, assume_unique=False, invert=False, method='auto'): ar2_min] return outgoing_array + elif method == 'dictionary': + raise ValueError( + "'dictionary' method is only supported for non-integer arrays. " + "Please select 'sort' or 'auto' for the method." + ) # Check if one of the arrays may contain arbitrary objects |