summaryrefslogtreecommitdiff
path: root/numpy/lib/arraysetops.py
diff options
context:
space:
mode:
authorMilesCranmer <miles.cranmer@gmail.com>2022-06-17 14:15:55 -0400
committerMilesCranmer <miles.cranmer@gmail.com>2022-06-17 14:15:55 -0400
commit31f739523f97afcec9baa6a872f25e06bd1a4104 (patch)
tree40f5ba69f6055789ffd90ba99abb30cb1e31f325 /numpy/lib/arraysetops.py
parentc5db8e86ebdcb54e33c93386a18b86615789fc50 (diff)
downloadnumpy-31f739523f97afcec9baa6a872f25e06bd1a4104.tar.gz
MAINT: Clean up memory checking for in1d
Diffstat (limited to 'numpy/lib/arraysetops.py')
-rw-r--r--numpy/lib/arraysetops.py20
1 files changed, 9 insertions, 11 deletions
diff --git a/numpy/lib/arraysetops.py b/numpy/lib/arraysetops.py
index a67472a22..a1eca1c01 100644
--- a/numpy/lib/arraysetops.py
+++ b/numpy/lib/arraysetops.py
@@ -641,21 +641,19 @@ def in1d(ar1, ar2, assume_unique=False, invert=False, kind=None):
try:
ar2_range = ar2_max - ar2_min
- # Optimal performance is for approximately
- # log10(size) > (log10(range) - 2.27) / 0.927.
- # However, here we set the requirement that
- # the intermediate array can only be 6x
- # the combined memory allocation of the original
- # arrays.
- # (see discussion on
- # https://github.com/numpy/numpy/pull/12065)
- below_memory_constraint = (
- ar2_range <= 6 * (ar1_size + ar2_size)
- )
range_safe_from_overflow = True
except FloatingPointError:
range_safe_from_overflow = False
+ # Optimal performance is for approximately
+ # log10(size) > (log10(range) - 2.27) / 0.927.
+ # However, here we set the requirement that
+ # the intermediate array can only be 6x
+ # the combined memory allocation of the original
+ # arrays. See discussion on
+ # https://github.com/numpy/numpy/pull/12065.
+ below_memory_constraint = ar2_range <= 6 * (ar1_size + ar2_size)
+
if (
range_safe_from_overflow and
(below_memory_constraint or kind == 'dictionary')