From 7ee97267ed1e21f808a96ec78577cf49903c535f Mon Sep 17 00:00:00 2001 From: Siu Kwan Lam <1929845+sklam@users.noreply.github.com> Date: Tue, 14 Mar 2023 13:36:14 -0500 Subject: [PATCH 1/3] Fix #8813. Increase ULP to 2 for logaddexp2 because LLVM14 SVML changed its precision on osx-64. --- numba/tests/test_ufuncs.py | 1 + 1 file changed, 1 insertion(+) diff --git a/numba/tests/test_ufuncs.py b/numba/tests/test_ufuncs.py index 0ebd1fdb726..f6248f41aab 100644 --- a/numba/tests/test_ufuncs.py +++ b/numba/tests/test_ufuncs.py @@ -1347,6 +1347,7 @@ class _LoopTypesTester(TestCase): ('log10', 'D'): 5, ('tanh', 'F'): 2, ('cbrt', 'd'): 2, + ('logaddexp2', 'd'): 2, } def _arg_for_type(self, a_letter_type, index=0): From f6a4580f5859189dea3f4e63640d34b2f2bfee79 Mon Sep 17 00:00:00 2001 From: Siu Kwan Lam <1929845+sklam@users.noreply.github.com> Date: Tue, 14 Mar 2023 13:48:13 -0500 Subject: [PATCH 2/3] Fix for 32-bit. Avoid hardcoding to int64 in argpartition --- numba/np/arraymath.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/numba/np/arraymath.py b/numba/np/arraymath.py index f13ecf456dc..67820c3e728 100644 --- a/numba/np/arraymath.py +++ b/numba/np/arraymath.py @@ -1830,7 +1830,7 @@ def np_argpartition_impl_inner(a, kth_array): # allocate and fill empty array rather than copy a and mutate in place # as the latter approach fails to preserve strides - out = np.empty_like(a, dtype=np.int64) + out = np.empty_like(a, dtype=np.intp) idx = np.ndindex(a.shape[:-1]) # Numpy default partition axis is -1 for s in idx: @@ -1924,7 +1924,7 @@ def np_argpartition(a, kth): def np_argpartition_impl(a, kth): a_tmp = _asarray(a) if a_tmp.size == 0: - return a_tmp.copy().astype('int64') + return a_tmp.copy().astype('intp') else: kth_array = valid_kths(a_tmp, kth) return np_argpartition_impl_inner(a_tmp, kth_array) From ae07d34ca74c73a01e40227bf718cca6df91b512 Mon Sep 17 00:00:00 2001 From: Siu Kwan Lam <1929845+sklam@users.noreply.github.com> Date: Tue, 14 Mar 2023 16:29:33 -0500 Subject: [PATCH 3/3] Fix test. Use expected result computed by numpy. --- numba/tests/test_np_functions.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/numba/tests/test_np_functions.py b/numba/tests/test_np_functions.py index 49e8422af0b..7d58d12df0c 100644 --- a/numba/tests/test_np_functions.py +++ b/numba/tests/test_np_functions.py @@ -2218,11 +2218,12 @@ def test_argpartition_basic(self): cfunc = jit(nopython=True)(pyfunc) d = np.array([], dtype=np.int64) + expected = pyfunc(d, 0) got = cfunc(d, 0) - self.assertPreciseEqual(d, got) + self.assertPreciseEqual(expected, got) d = np.ones(1, dtype=np.int64) - expected = np.zeros(1, dtype=np.int64) + expected = pyfunc(d, 0) got = cfunc(d, 0) self.assertPreciseEqual(expected, got)