diff options
author | MilesCranmer <miles.cranmer@gmail.com> | 2022-06-18 13:49:03 -0400 |
---|---|---|
committer | MilesCranmer <miles.cranmer@gmail.com> | 2022-06-18 13:49:03 -0400 |
commit | 4ed458f16d9dd64554ccf49e315c5b8fb577d4cd (patch) | |
tree | 9f0f1e179ced5161ef21a3ba8fcbcfe16f3f07f0 /numpy/lib/arraysetops.py | |
parent | d9d4fd5b0ba38e52e6261ef51e5cd47cdddfdf1e (diff) | |
download | numpy-4ed458f16d9dd64554ccf49e315c5b8fb577d4cd.tar.gz |
MAINT: change kind names for in1d
- Switch dictionary->table, mergesort->sort
Diffstat (limited to 'numpy/lib/arraysetops.py')
-rw-r--r-- | numpy/lib/arraysetops.py | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/numpy/lib/arraysetops.py b/numpy/lib/arraysetops.py index 5102a5d06..56080382c 100644 --- a/numpy/lib/arraysetops.py +++ b/numpy/lib/arraysetops.py @@ -545,27 +545,27 @@ def in1d(ar1, ar2, assume_unique=False, invert=False, kind=None): False where an element of `ar1` is in `ar2` and True otherwise). Default is False. ``np.in1d(a, b, invert=True)`` is equivalent to (but is faster than) ``np.invert(in1d(a, b))``. - kind : {None, 'mergesort', 'dictionary'}, optional + kind : {None, 'sort', 'table'}, optional The algorithm to use. This will not affect the final result, but will affect the speed. Default will select automatically based on memory considerations. - * If 'mergesort', will use a mergesort-based approach. This will have + * If 'sort', will use a mergesort-based approach. This will have a memory usage of roughly 6 times the sum of the sizes of `ar1` and `ar2`, not accounting for size of dtypes. - * If 'dictionary', will use a key-dictionary approach similar + * If 'table', will use a key-dictionary approach similar to a counting sort. This is only available for boolean and integer arrays. This will have a memory usage of the size of `ar1` plus the max-min value of `ar2`. This tends to be the faster method if the following formula is true: ``log10(len(ar2)) > (log10(max(ar2)-min(ar2)) - 2.27) / 0.927``, but may use greater memory. - * If `None`, will automatically choose 'dictionary' if + * If `None`, will automatically choose 'table' if the required memory allocation is less than or equal to 6 times the sum of the sizes of `ar1` and `ar2`, - otherwise will use 'mergesort'. This is done to not use + otherwise will use 'sort'. This is done to not use a large amount of memory by default, even though - 'dictionary' may be faster in most cases. + 'table' may be faster in most cases. .. versionadded:: 1.8.0 @@ -625,18 +625,18 @@ def in1d(ar1, ar2, assume_unique=False, invert=False, kind=None): integer_arrays = (np.issubdtype(ar1.dtype, np.integer) and np.issubdtype(ar2.dtype, np.integer)) - if kind not in {None, 'mergesort', 'dictionary'}: + if kind not in {None, 'sort', 'table'}: raise ValueError( "Invalid kind: {0}. ".format(kind) - + "Please use None, 'mergesort' or 'dictionary'.") + + "Please use None, 'sort' or 'table'.") - if integer_arrays and kind in {None, 'dictionary'}: + if integer_arrays and kind in {None, 'table'}: ar2_min = np.min(ar2) ar2_max = np.max(ar2) ar2_range = int(ar2_max) - int(ar2_min) - # Constraints on whether we can actually use the dictionary method: + # Constraints on whether we can actually use the table method: range_safe_from_overflow = ar2_range < np.iinfo(ar2.dtype).max below_memory_constraint = ar2_range <= 6 * (ar1.size + ar2.size) @@ -650,7 +650,7 @@ def in1d(ar1, ar2, assume_unique=False, invert=False, kind=None): if ( range_safe_from_overflow and - (below_memory_constraint or kind == 'dictionary') + (below_memory_constraint or kind == 'table') ): if invert: @@ -672,18 +672,18 @@ def in1d(ar1, ar2, assume_unique=False, invert=False, kind=None): ar2_min] return outgoing_array - elif kind == 'dictionary': # not range_safe_from_overflow + elif kind == 'table': # not range_safe_from_overflow raise RuntimeError( - "You have specified kind='dictionary', " + "You have specified kind='table', " "but the range of values in `ar2` exceeds the " "maximum integer of the datatype. " - "Please set `kind` to None or 'mergesort'." + "Please set `kind` to None or 'sort'." ) - elif kind == 'dictionary': + elif kind == 'table': raise ValueError( - "The 'dictionary' method is only " + "The 'table' method is only " "supported for boolean or integer arrays. " - "Please select 'mergesort' or None for kind." + "Please select 'sort' or None for kind." ) @@ -759,27 +759,27 @@ def isin(element, test_elements, assume_unique=False, invert=False, calculating `element not in test_elements`. Default is False. ``np.isin(a, b, invert=True)`` is equivalent to (but faster than) ``np.invert(np.isin(a, b))``. - kind : {None, 'mergesort', 'dictionary'}, optional + kind : {None, 'sort', 'table'}, optional The algorithm to use. This will not affect the final result, but will affect the speed. Default will select automatically based on memory considerations. - * If 'mergesort', will use a mergesort-based approach. This will have + * If 'sort', will use a mergesort-based approach. This will have a memory usage of roughly 6 times the sum of the sizes of `ar1` and `ar2`, not accounting for size of dtypes. - * If 'dictionary', will use a key-dictionary approach similar + * If 'table', will use a key-dictionary approach similar to a counting sort. This is only available for boolean and integer arrays. This will have a memory usage of the size of `ar1` plus the max-min value of `ar2`. This tends to be the faster method if the following formula is true: ``log10(len(ar2)) > (log10(max(ar2)-min(ar2)) - 2.27) / 0.927``, but may use greater memory. - * If `None`, will automatically choose 'dictionary' if + * If `None`, will automatically choose 'table' if the required memory allocation is less than or equal to 6 times the sum of the sizes of `ar1` and `ar2`, - otherwise will use 'mergesort'. This is done to not use + otherwise will use 'sort'. This is done to not use a large amount of memory by default, even though - 'dictionary' may be faster in most cases. + 'table' may be faster in most cases. Returns |