From 31f739523f97afcec9baa6a872f25e06bd1a4104 Mon Sep 17 00:00:00 2001 From: MilesCranmer Date: Fri, 17 Jun 2022 14:15:55 -0400 Subject: MAINT: Clean up memory checking for in1d --- numpy/lib/arraysetops.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'numpy/lib/arraysetops.py') 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') -- cgit v1.2.1