From 9a6554a1b6cfeeb27c58fc3bc9ec72be03a6a1cf Mon Sep 17 00:00:00 2001 From: Graham Markall Date: Thu, 24 Nov 2022 15:41:24 +0000 Subject: [PATCH 01/18] CUDA intrinsics tests: correct np.float -> np.float16 I believe this was written in error and should always have been float16. --- numba/cuda/tests/cudapy/test_intrinsics.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/numba/cuda/tests/cudapy/test_intrinsics.py b/numba/cuda/tests/cudapy/test_intrinsics.py index f72e88b8e45..99c0ee5007b 100644 --- a/numba/cuda/tests/cudapy/test_intrinsics.py +++ b/numba/cuda/tests/cudapy/test_intrinsics.py @@ -833,7 +833,7 @@ def test_hmax(self): arg2 = np.float16(4.) compiled[1, 1](ary, arg1, arg2) np.testing.assert_allclose(ary[0], arg2) - arg1 = np.float(5.) + arg1 = np.float16(5.) compiled[1, 1](ary, arg1, arg2) np.testing.assert_allclose(ary[0], arg1) @@ -845,7 +845,7 @@ def test_hmin(self): arg2 = np.float16(4.) compiled[1, 1](ary, arg1, arg2) np.testing.assert_allclose(ary[0], arg1) - arg1 = np.float(5.) + arg1 = np.float16(5.) compiled[1, 1](ary, arg1, arg2) np.testing.assert_allclose(ary[0], arg2) From 83d08f663c057f9c7e889088f5db3312858a590a Mon Sep 17 00:00:00 2001 From: Graham Markall Date: Thu, 22 Dec 2022 13:02:22 +0000 Subject: [PATCH 02/18] TestLinalgSvd.test_no_input_mutation: use reconstruction if necessary This test only checked for a plain match when comparing outputs. However, in some cases a reconstruction check can be necessary, as in `test_linalg_svd`. --- numba/tests/test_linalg.py | 61 ++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/numba/tests/test_linalg.py b/numba/tests/test_linalg.py index 96faae5300c..1ef259e2268 100644 --- a/numba/tests/test_linalg.py +++ b/numba/tests/test_linalg.py @@ -1124,6 +1124,32 @@ class TestLinalgSvd(TestLinalgBase): Tests for np.linalg.svd. """ + # This checks that A ~= U*S*V**H, i.e. SV decomposition ties out. This is + # required as NumPy uses only double precision LAPACK routines and + # computation of SVD is numerically sensitive. Numba uses type-specific + # routines and therefore sometimes comes out with a different answer to + # NumPy (orthonormal bases are not unique, etc.). + + def check_reconstruction(self, a, got, expected): + u, sv, vt = got + + # Check they are dimensionally correct + for k in range(len(expected)): + self.assertEqual(got[k].shape, expected[k].shape) + + # Columns in u and rows in vt dictates the working size of s + s = np.zeros((u.shape[1], vt.shape[0])) + np.fill_diagonal(s, sv) + + rec = np.dot(np.dot(u, s), vt) + resolution = np.finfo(a.dtype).resolution + np.testing.assert_allclose( + a, + rec, + rtol=10 * resolution, + atol=100 * resolution # zeros tend to be fuzzy + ) + @needs_lapack def test_linalg_svd(self): """ @@ -1152,34 +1178,8 @@ def check(a, **kwargs): # plain match failed, test by reconstruction use_reconstruction = True - # if plain match fails then reconstruction is used. - # this checks that A ~= U*S*V**H - # i.e. SV decomposition ties out - # this is required as numpy uses only double precision lapack - # routines and computation of svd is numerically - # sensitive, numba using the type specific routines therefore - # sometimes comes out with a different answer (orthonormal bases - # are not unique etc.). if use_reconstruction: - u, sv, vt = got - - # check they are dimensionally correct - for k in range(len(expected)): - self.assertEqual(got[k].shape, expected[k].shape) - - # regardless of full_matrices cols in u and rows in vt - # dictates the working size of s - s = np.zeros((u.shape[1], vt.shape[0])) - np.fill_diagonal(s, sv) - - rec = np.dot(np.dot(u, s), vt) - resolution = np.finfo(a.dtype).resolution - np.testing.assert_allclose( - a, - rec, - rtol=10 * resolution, - atol=100 * resolution # zeros tend to be fuzzy - ) + self.check_reconstruction(a, got, expected) # Ensure proper resource management with self.assertNoNRTLeak(): @@ -1240,8 +1240,11 @@ def func(X, test): got = func(X, False) np.testing.assert_allclose(X, X_orig) - for e_a, g_a in zip(expected, got): - np.testing.assert_allclose(e_a, g_a) + try: + for e_a, g_a in zip(expected, got): + np.testing.assert_allclose(e_a, g_a) + except AssertionError: + self.check_reconstruction(X, got, expected) class TestLinalgQr(TestLinalgBase): From 4c619e6ef6baacf1db53ff04b53a2b3942b74463 Mon Sep 17 00:00:00 2001 From: Graham Markall Date: Thu, 24 Nov 2022 21:39:27 +0000 Subject: [PATCH 03/18] test_comp_nest_with_dependency: skip on NumPy 1.24 Setting an array element with a sequence is removed in NumPy 1.24. --- numba/tests/test_comprehension.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/numba/tests/test_comprehension.py b/numba/tests/test_comprehension.py index 2cdd3dc2511..092ed51dac4 100644 --- a/numba/tests/test_comprehension.py +++ b/numba/tests/test_comprehension.py @@ -11,6 +11,7 @@ from numba.core import types, utils from numba.core.errors import TypingError, LoweringError from numba.core.types.functions import _header_lead +from numba.np.numpy_support import numpy_version from numba.tests.support import tag, _32bit, captured_stdout @@ -360,6 +361,7 @@ def comp_nest_with_array_conditional(n): self.check(comp_nest_with_array_conditional, 5, assert_allocate_list=True) + @unittest.skipUnless(numpy_version < (1, 24), 'Removed in NumPy 1.24') def test_comp_nest_with_dependency(self): def comp_nest_with_dependency(n): l = np.array([[i * j for j in range(i+1)] for i in range(n)]) From f5f5b740504a2dce604a1cf8a58611ca5f7b01da Mon Sep 17 00:00:00 2001 From: Graham Markall Date: Thu, 24 Nov 2022 16:48:37 +0000 Subject: [PATCH 04/18] Avoid use of np.bool in stencilparfor.py --- numba/stencils/stencilparfor.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/numba/stencils/stencilparfor.py b/numba/stencils/stencilparfor.py index 5f30893b32d..4f23ed903e8 100644 --- a/numba/stencils/stencilparfor.py +++ b/numba/stencils/stencilparfor.py @@ -21,6 +21,7 @@ find_callname, require, find_const, GuardException) from numba.core.errors import NumbaValueError from numba.core.utils import OPERATORS_TO_BUILTINS +from numba.np import numpy_support def _compute_last_ind(dim_size, index_const): @@ -264,7 +265,11 @@ def _mk_stencil_parfor(self, label, in_args, out_arr, stencil_ir, dtype_g_np_assign = ir.Assign(dtype_g_np, dtype_g_np_var, loc) init_block.body.append(dtype_g_np_assign) - dtype_np_attr_call = ir.Expr.getattr(dtype_g_np_var, return_type.dtype.name, loc) + return_type_name = numpy_support.as_dtype( + return_type.dtype).type.__name__ + if return_type_name == 'bool': + return_type_name = 'bool_' + dtype_np_attr_call = ir.Expr.getattr(dtype_g_np_var, return_type_name, loc) dtype_attr_var = ir.Var(scope, mk_unique_var("$np_attr_attr"), loc) self.typemap[dtype_attr_var.name] = types.functions.NumberClass(return_type.dtype) dtype_attr_assign = ir.Assign(dtype_np_attr_call, dtype_attr_var, loc) From 90afbcad31cd949b46ddaa8d2ae357532069104f Mon Sep 17 00:00:00 2001 From: Graham Markall Date: Thu, 24 Nov 2022 15:46:52 +0000 Subject: [PATCH 05/18] test_hypot: Tweak regex so it matches NumPy 1.24 The modified regex matches the existing message produced by NumPy < 1.24, and the new improved message in 1.24. --- numba/tests/test_mathlib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numba/tests/test_mathlib.py b/numba/tests/test_mathlib.py index a3f535316e3..05e3d68f59a 100644 --- a/numba/tests/test_mathlib.py +++ b/numba/tests/test_mathlib.py @@ -516,7 +516,7 @@ def naive_hypot(x, y): with warnings.catch_warnings(): warnings.simplefilter("error", RuntimeWarning) self.assertRaisesRegexp(RuntimeWarning, - 'overflow encountered in .*_scalars', + 'overflow encountered in .*scalar', naive_hypot, val, val) def test_hypot_npm(self): From 99966f46059d8e1a6d9856609aae06929a4122a2 Mon Sep 17 00:00:00 2001 From: Graham Markall Date: Thu, 24 Nov 2022 11:29:53 +0000 Subject: [PATCH 06/18] Don't test summing with timedelta dtype This always produced invalid results (though they were consistent between Numba and NumPy) but now this fails in NumPy 1.24 with an exception: ``` TypeError: The `dtype` and `signature` arguments to ufuncs only select the general DType and not details such as the byte order or time unit. You can avoid this error by using the scalar types `np.float64` or the dtype string notation. ``` Note that the exception message is misleading, and using the dtype string notation does not provide a workaround. --- numba/tests/test_array_methods.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/numba/tests/test_array_methods.py b/numba/tests/test_array_methods.py index 2318b740822..c24cd7b90da 100644 --- a/numba/tests/test_array_methods.py +++ b/numba/tests/test_array_methods.py @@ -1337,7 +1337,7 @@ def test_sum_dtype_kws(self): pyfunc = array_sum_dtype_kws cfunc = jit(nopython=True)(pyfunc) all_dtypes = [np.float64, np.float32, np.int64, np.int32, np.uint32, - np.uint64, np.complex64, np.complex128, TIMEDELTA_M] + np.uint64, np.complex64, np.complex128] all_test_arrays = [ [np.ones((7, 6, 5, 4, 3), arr_dtype), np.ones(1, arr_dtype), @@ -1351,8 +1351,7 @@ def test_sum_dtype_kws(self): np.dtype('uint32'): [np.float64, np.int64, np.float32], np.dtype('uint64'): [np.float64, np.int64], np.dtype('complex64'): [np.complex64, np.complex128], - np.dtype('complex128'): [np.complex128], - np.dtype(TIMEDELTA_M): [np.dtype(TIMEDELTA_M)]} + np.dtype('complex128'): [np.complex128]} for arr_list in all_test_arrays: for arr in arr_list: @@ -1360,15 +1359,15 @@ def test_sum_dtype_kws(self): subtest_str = ("Testing np.sum with {} input and {} output" .format(arr.dtype, out_dtype)) with self.subTest(subtest_str): - self.assertPreciseEqual(pyfunc(arr, dtype=out_dtype), - cfunc(arr, dtype=out_dtype)) + self.assertPreciseEqual(pyfunc(arr, dtype=out_dtype), + cfunc(arr, dtype=out_dtype)) def test_sum_axis_dtype_kws(self): """ test sum with axis and dtype parameters over a whole range of dtypes """ pyfunc = array_sum_axis_dtype_kws cfunc = jit(nopython=True)(pyfunc) all_dtypes = [np.float64, np.float32, np.int64, np.int32, np.uint32, - np.uint64, np.complex64, np.complex128, TIMEDELTA_M] + np.uint64, np.complex64, np.complex128] all_test_arrays = [ [np.ones((7, 6, 5, 4, 3), arr_dtype), np.ones(1, arr_dtype), @@ -1382,9 +1381,7 @@ def test_sum_axis_dtype_kws(self): np.dtype('uint32'): [np.float64, np.int64, np.float32], np.dtype('uint64'): [np.float64, np.uint64], np.dtype('complex64'): [np.complex64, np.complex128], - np.dtype('complex128'): [np.complex128], - np.dtype(TIMEDELTA_M): [np.dtype(TIMEDELTA_M)], - np.dtype(TIMEDELTA_Y): [np.dtype(TIMEDELTA_Y)]} + np.dtype('complex128'): [np.complex128]} for arr_list in all_test_arrays: for arr in arr_list: From 937f7f8bd1b16a170f924aaabc96826d528bd5da Mon Sep 17 00:00:00 2001 From: Graham Markall Date: Thu, 24 Nov 2022 10:03:54 +0000 Subject: [PATCH 07/18] Replace use of deprecated np.bool with np.bool_ np.bool was removed in NumPy 1.24. --- numba/tests/test_np_functions.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/numba/tests/test_np_functions.py b/numba/tests/test_np_functions.py index 899317f1f0f..0d02b9eb77f 100644 --- a/numba/tests/test_np_functions.py +++ b/numba/tests/test_np_functions.py @@ -961,11 +961,11 @@ def values(): yield np.inf, None yield np.PINF, None yield np.asarray([-np.inf, 0., np.inf]), None - yield np.NINF, np.zeros(1, dtype=np.bool) - yield np.inf, np.zeros(1, dtype=np.bool) - yield np.PINF, np.zeros(1, dtype=np.bool) + yield np.NINF, np.zeros(1, dtype=np.bool_) + yield np.inf, np.zeros(1, dtype=np.bool_) + yield np.PINF, np.zeros(1, dtype=np.bool_) yield np.NINF, np.empty(12) - yield np.asarray([-np.inf, 0., np.inf]), np.zeros(3, dtype=np.bool) + yield np.asarray([-np.inf, 0., np.inf]), np.zeros(3, dtype=np.bool_) pyfuncs = [isneginf, isposinf] for pyfunc in pyfuncs: From cd867db451c75c79b9884fd2262a7f318ab5d4f8 Mon Sep 17 00:00:00 2001 From: Graham Markall Date: Thu, 24 Nov 2022 09:56:06 +0000 Subject: [PATCH 08/18] Overload np.MachAr only for NumPy < 1.24 --- numba/np/arraymath.py | 4 ++++ numba/tests/test_np_functions.py | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/numba/np/arraymath.py b/numba/np/arraymath.py index 7c7f0722f3a..74630b95fe9 100644 --- a/numba/np/arraymath.py +++ b/numba/np/arraymath.py @@ -3964,6 +3964,10 @@ def histogram_impl(a, bins=10, range=None): # This module is imported under the compiler lock which should deal with the # lack of thread safety in the warning filter. def _gen_np_machar(): + # NumPy 1.24 removed np.MachAr + if numpy_version >= (1, 24): + return + np122plus = numpy_version >= (1, 22) w = None with warnings.catch_warnings(record=True) as w: diff --git a/numba/tests/test_np_functions.py b/numba/tests/test_np_functions.py index 0d02b9eb77f..48872e7096d 100644 --- a/numba/tests/test_np_functions.py +++ b/numba/tests/test_np_functions.py @@ -4893,6 +4893,7 @@ def create_harcoded_variant(self, basefunc, ty): eval(compile(funcstr, '', 'exec')) return locals()['foo'] + @unittest.skipIf(numpy_version >= (1, 24), "NumPy < 1.24 required") def test_MachAr(self): attrs = ('ibeta', 'it', 'machep', 'eps', 'negep', 'epsneg', 'iexp', 'minexp', 'xmin', 'maxexp', 'xmax', 'irnd', 'ngrd', @@ -4935,7 +4936,8 @@ def test_iinfo(self): cfunc = jit(nopython=True)(iinfo) cfunc(np.float64(7)) - @unittest.skipUnless(numpy_version >= (1, 22), "Needs NumPy >= 1.22") + @unittest.skipUnless((1, 22) <= numpy_version < (1, 24), + "Needs NumPy >= 1.22, < 1.24") @TestCase.run_test_in_subprocess def test_np_MachAr_deprecation_np122(self): # Tests that Numba is replaying the NumPy 1.22 deprecation warning From 8d8abd1589cb99a961485166af559aa3ecd90f23 Mon Sep 17 00:00:00 2001 From: Graham Markall Date: Fri, 25 Nov 2022 10:55:04 +0000 Subject: [PATCH 09/18] _internal.c: Remove NPY_API_VERSION checks The API version has long since been greater than 0x7 / 0x8 for any supported NumPy. --- numba/np/ufunc/_internal.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/numba/np/ufunc/_internal.c b/numba/np/ufunc/_internal.c index 3a6089292f5..0d9dd34f181 100644 --- a/numba/np/ufunc/_internal.c +++ b/numba/np/ufunc/_internal.c @@ -306,9 +306,7 @@ static struct _ufunc_dispatch { PyCFunctionWithKeywords ufunc_accumulate; PyCFunctionWithKeywords ufunc_reduceat; PyCFunctionWithKeywords ufunc_outer; -#if NPY_API_VERSION >= 0x00000008 PyCFunction ufunc_at; -#endif } ufunc_dispatch; static int @@ -324,10 +322,8 @@ init_ufunc_dispatch(int *numpy_uses_fastcall) if (strncmp(crnt_name, "accumulate", 11) == 0) { ufunc_dispatch.ufunc_accumulate = (PyCFunctionWithKeywords)crnt->ml_meth; -#if NPY_API_VERSION >= 0x00000008 } else if (strncmp(crnt_name, "at", 3) == 0) { ufunc_dispatch.ufunc_at = crnt->ml_meth; -#endif } else { result = -1; } @@ -372,9 +368,7 @@ init_ufunc_dispatch(int *numpy_uses_fastcall) && (ufunc_dispatch.ufunc_accumulate != NULL) && (ufunc_dispatch.ufunc_reduceat != NULL) && (ufunc_dispatch.ufunc_outer != NULL) -#if NPY_API_VERSION >= 0x00000008 && (ufunc_dispatch.ufunc_at != NULL) -#endif ); } return result; @@ -446,13 +440,11 @@ dufunc_outer_fast(PyDUFuncObject * self, } -#if NPY_API_VERSION >= 0x00000008 static PyObject * dufunc_at(PyDUFuncObject * self, PyObject * args) { return ufunc_dispatch.ufunc_at((PyObject*)self->ufunc, args); } -#endif static PyObject * dufunc__compile_for_args(PyDUFuncObject * self, PyObject * args, @@ -630,11 +622,9 @@ static struct PyMethodDef dufunc_methods[] = { {"outer", (PyCFunction)dufunc_outer, METH_VARARGS | METH_KEYWORDS, NULL}, -#if NPY_API_VERSION >= 0x00000008 {"at", (PyCFunction)dufunc_at, METH_VARARGS, NULL}, -#endif {"_compile_for_args", (PyCFunction)dufunc__compile_for_args, METH_VARARGS | METH_KEYWORDS, @@ -664,11 +654,9 @@ static struct PyMethodDef dufunc_methods_fast[] = { {"outer", (PyCFunction)dufunc_outer_fast, METH_FASTCALL | METH_KEYWORDS, NULL}, -#if NPY_API_VERSION >= 0x00000008 {"at", (PyCFunction)dufunc_at, METH_VARARGS, NULL}, -#endif {"_compile_for_args", (PyCFunction)dufunc__compile_for_args, METH_VARARGS | METH_KEYWORDS, @@ -837,9 +825,7 @@ MOD_INIT(_internal) if (PyModule_AddIntMacro(m, PyUFunc_One) || PyModule_AddIntMacro(m, PyUFunc_Zero) || PyModule_AddIntMacro(m, PyUFunc_None) -#if NPY_API_VERSION >= 0x00000007 || PyModule_AddIntMacro(m, PyUFunc_ReorderableNone) -#endif ) return MOD_ERROR_VAL; From 915a23700fea1010cf60b9f59716976c4d21845b Mon Sep 17 00:00:00 2001 From: Graham Markall Date: Tue, 3 Jan 2023 17:08:44 +0000 Subject: [PATCH 10/18] init_ufunc_dispatch: Handle unexpected ufunc methods gracefully If an unexpected ufunc method was encountered, `init_ufunc_dispatch()` would return an error code indicating failure without setting an exception, leading to errors like ``` SystemError: initialization of _internal failed without raising an exception ``` as reported in Issue #8615. This commit fixes the issue by setting an appropriate exception in this case. --- numba/np/ufunc/_internal.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/numba/np/ufunc/_internal.c b/numba/np/ufunc/_internal.c index 0d9dd34f181..c9b81076e60 100644 --- a/numba/np/ufunc/_internal.c +++ b/numba/np/ufunc/_internal.c @@ -358,6 +358,8 @@ init_ufunc_dispatch(int *numpy_uses_fastcall) *numpy_uses_fastcall = crnt->ml_flags & METH_FASTCALL; } else if (*numpy_uses_fastcall != (crnt->ml_flags & METH_FASTCALL)) { + PyErr_SetString(PyExc_RuntimeError, + "ufunc.at() flags do not match numpy_uses_fastcall"); return -1; } } @@ -370,7 +372,11 @@ init_ufunc_dispatch(int *numpy_uses_fastcall) && (ufunc_dispatch.ufunc_outer != NULL) && (ufunc_dispatch.ufunc_at != NULL) ); + } else { + char const * const fmt = "Unexpected ufunc method %s()"; + PyErr_Format(PyExc_RuntimeError, fmt, crnt_name); } + return result; } From da739e13e86ff48b82649516dffcf0c1c81c3155 Mon Sep 17 00:00:00 2001 From: Graham Markall Date: Tue, 3 Jan 2023 17:11:10 +0000 Subject: [PATCH 11/18] init_ufunc_dispatch: Update for NumPy 1.24 NumPy 1.24 adds a new method, `resolve_dtypes()`, and a private method `_resolve_dtypes_and_context()`. We handle these by just ignoring them (ignoring all private methods in general) in order to provide the same level of functionality in Numba as for NumPy 1.23. There is further room to build new functionality on top of this: - Providing an implementation of `resolve_dtypes()` for `DUFunc` objects. - Using the `resolve_dtypes()` method in place of logic in Numba that implements a similar dtype resolution process. --- numba/np/ufunc/_internal.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/numba/np/ufunc/_internal.c b/numba/np/ufunc/_internal.c index c9b81076e60..6d412f9332c 100644 --- a/numba/np/ufunc/_internal.c +++ b/numba/np/ufunc/_internal.c @@ -343,10 +343,15 @@ init_ufunc_dispatch(int *numpy_uses_fastcall) } else if (strncmp(crnt_name, "reduceat", 9) == 0) { ufunc_dispatch.ufunc_reduceat = (PyCFunctionWithKeywords)crnt->ml_meth; + } else if (strncmp(crnt_name, "resolve_dtypes", 15) == 0) { + /* Ignored */ } else { result = -1; } break; + case '_': + // We ignore private methods + break; default: result = -1; /* Unknown method */ } From a4a0b8d33d59d5999eef7259ccb733b8d20f33ac Mon Sep 17 00:00:00 2001 From: Graham Markall Date: Tue, 3 Jan 2023 12:14:07 +0000 Subject: [PATCH 12/18] Update NumPy version support documentation --- docs/source/user/installing.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/user/installing.rst b/docs/source/user/installing.rst index d2a88a52ee6..532c417c66c 100644 --- a/docs/source/user/installing.rst +++ b/docs/source/user/installing.rst @@ -5,7 +5,7 @@ Installation Compatibility ------------- -Numba is compatible with Python 3.8--3.10, and NumPy versions 1.18 or later. +Numba is compatible with Python 3.8--3.10, and NumPy versions 1.21--1.24. Our supported platforms are: @@ -257,7 +257,7 @@ information. +----------++--------------+---------------------------+----------------------------+------------------------------+-------------------+-----------------------------+ | Numba | Release date | Python | NumPy | llvmlite | LLVM | TBB | +===========+==============+===========================+============================+==============================+===================+=============================+ -| 0.57.x | TBC | 3.8.x <= version < 3.12 | 1.19 <= version < 1.24 | 0.40.x | 11.x | 2021.x | +| 0.57.0 | TBC | 3.8.x <= version < 3.12 | 1.21 <= version < 1.24 | 0.40.x | 11.x | 2021.x | +-----------+--------------+---------------------------+----------------------------+------------------------------+-------------------+-----------------------------+ | 0.56.4 | 2022-11-03 | 3.7.x <= version < 3.11 | 1.18 <= version < 1.24 | 0.39.x | 11.x | 2021.x | +-----------+--------------+---------------------------+----------------------------+------------------------------+-------------------+-----------------------------+ From 9ffee5d55d8a01be750ef7970847a3d847c9339e Mon Sep 17 00:00:00 2001 From: Graham Markall Date: Tue, 3 Jan 2023 17:28:35 +0000 Subject: [PATCH 13/18] Mody test matrix to test NumPy versions 1.21-1.24 This results in the following output from `print_azure_matrix()`: ``` NumPy | Python | Count ----------------------- 1.21 | 3.8 | 4 1.22 | 3.8 | 4 1.22 | 3.9 | 1 1.23 | 3.8 | 2 1.23 | 3.9 | 2 1.23 | 3.10 | 1 1.24 | 3.10 | 3 1.24 | 3.8 | 1 1.24 | 3.9 | 1 ``` There are 19 slices, so the aim was to have five slices for each NumPy version (1.21, 1.22, 1.23, 1.24) except for 1.21 which has 4 slices. --- azure-pipelines.yml | 68 ++++++++++++++-------------- buildscripts/azure/azure-windows.yml | 8 ++-- buildscripts/gpuci/build.sh | 2 +- 3 files changed, 39 insertions(+), 39 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 7ec8e708036..186332669b4 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -12,14 +12,14 @@ jobs: name: macOS vmImage: macos-11 matrix: - py38_np118: + py38_np121: PYTHON: '3.8' - NUMPY: '1.18' + NUMPY: '1.21' CONDA_ENV: 'azure_ci' TEST_START_INDEX: 0 - py310_np123: + py310_np124: PYTHON: '3.10' - NUMPY: '1.23' + NUMPY: '1.24' CONDA_ENV: 'azure_ci' TEST_THREADING: 'tbb' TEST_START_INDEX: 1 @@ -29,89 +29,89 @@ jobs: name: Linux vmImage: ubuntu-20.04 matrix: - py38_np118_vanilla: + py38_np121_vanilla: PYTHON: '3.8' - NUMPY: '1.18' + NUMPY: '1.21' CONDA_ENV: azure_ci VANILLA_INSTALL: yes TEST_START_INDEX: 2 - py38_np118_cov: + py38_np121_cov: PYTHON: '3.8' - NUMPY: '1.18' + NUMPY: '1.21' CONDA_ENV: azure_ci RUN_COVERAGE: yes RUN_FLAKE8: yes RUN_MYPY: yes TEST_START_INDEX: 3 - py38_np119_tbb: + py38_np122_tbb: PYTHON: '3.8' - NUMPY: '1.19.2=*_0' + NUMPY: '1.22' CONDA_ENV: azure_ci TEST_THREADING: 'tbb' TEST_START_INDEX: 4 - py38_np119_omp: + py38_np122_omp: PYTHON: '3.8' - NUMPY: '1.19.2=*_0' + NUMPY: '1.22' CONDA_ENV: azure_ci TEST_THREADING: omp TEST_START_INDEX: 5 - py38_np119_workqueue: + py38_np122_workqueue: PYTHON: '3.8' - NUMPY: '1.19.2=*_0' + NUMPY: '1.22' CONDA_ENV: azure_ci TEST_THREADING: workqueue TEST_START_INDEX: 6 - py38_np120_doc: + py38_np123_doc: PYTHON: '3.8' - NUMPY: '1.20' + NUMPY: '1.23' CONDA_ENV: azure_ci BUILD_DOC: yes TEST_START_INDEX: 7 - py38_np120: + py38_np122: PYTHON: '3.8' - NUMPY: '1.20' + NUMPY: '1.22' CONDA_ENV: azure_ci TEST_START_INDEX: 8 - py38_np120_svml: + py38_np123_svml: PYTHON: '3.8' - NUMPY: '1.20' + NUMPY: '1.23' CONDA_ENV: azure_ci TEST_SVML: yes TEST_START_INDEX: 9 - py38_np122: + py38_np124: PYTHON: '3.8' - NUMPY: '1.22' + NUMPY: '1.24' CONDA_ENV: azure_ci TEST_START_INDEX: 10 - py39_np119: + py39_np123: PYTHON: '3.9' - NUMPY: '1.19.2=*_0' + NUMPY: '1.23' CONDA_ENV: azure_ci TEST_START_INDEX: 11 - py39_np120_typeguard: + py39_np123_typeguard: PYTHON: '3.9' - NUMPY: '1.20' + NUMPY: '1.23' CONDA_ENV: azure_ci RUN_TYPEGUARD: yes TEST_START_INDEX: 12 - py39_np121: + py39_np122: PYTHON: '3.9' - NUMPY: '1.21' + NUMPY: '1.22' CONDA_ENV: azure_ci TEST_START_INDEX: 13 - py39_np123: + py39_np124: PYTHON: '3.9' - NUMPY: '1.23' + NUMPY: '1.24' CONDA_ENV: azure_ci TEST_START_INDEX: 14 - py310_np121: + py310_np123: PYTHON: '3.10' - NUMPY: '1.21' + NUMPY: '1.23' CONDA_ENV: azure_ci TEST_START_INDEX: 15 - py310_np123: + py310_np124: PYTHON: '3.10' - NUMPY: '1.23' + NUMPY: '1.24' CONDA_ENV: azure_ci TEST_START_INDEX: 16 diff --git a/buildscripts/azure/azure-windows.yml b/buildscripts/azure/azure-windows.yml index 77a9907e012..2d5171bf8f0 100644 --- a/buildscripts/azure/azure-windows.yml +++ b/buildscripts/azure/azure-windows.yml @@ -8,14 +8,14 @@ jobs: vmImage: ${{ parameters.vmImage }} strategy: matrix: - py310_np123: + py310_np124: PYTHON: '3.10' - NUMPY: '1.23' + NUMPY: '1.24' CONDA_ENV: 'testenv' TEST_START_INDEX: 17 - py38_np118: + py38_np121: PYTHON: '3.8' - NUMPY: '1.18' + NUMPY: '1.21' CONDA_ENV: 'testenv' TEST_START_INDEX: 18 diff --git a/buildscripts/gpuci/build.sh b/buildscripts/gpuci/build.sh index 262b1a3982e..ac05e37d2cc 100644 --- a/buildscripts/gpuci/build.sh +++ b/buildscripts/gpuci/build.sh @@ -27,7 +27,7 @@ fi; # Test with different NumPy versions with each toolkit (it's not worth testing # the Cartesian product of versions here, we just need to test with different # CUDA and NumPy versions). -declare -A CTK_NUMPY_VMAP=( ["11.0"]="1.19" ["11.1"]="1.21" ["11.2"]="1.22" ["11.5"]="1.23") +declare -A CTK_NUMPY_VMAP=( ["11.0"]="1.21" ["11.1"]="1.22" ["11.2"]="1.23" ["11.5"]="1.24") NUMPY_VER="${CTK_NUMPY_VMAP[$CUDA_TOOLKIT_VER]}" From 334be3b04b04808c87688ed80ed1a556ceefb99b Mon Sep 17 00:00:00 2001 From: Graham Markall Date: Wed, 11 Jan 2023 16:19:32 +0000 Subject: [PATCH 14/18] Docs: Correct NumPy upper bound for 0.57 release From PR #8691 feedback. --- docs/source/user/installing.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/user/installing.rst b/docs/source/user/installing.rst index 532c417c66c..fa7339f691b 100644 --- a/docs/source/user/installing.rst +++ b/docs/source/user/installing.rst @@ -257,7 +257,7 @@ information. +----------++--------------+---------------------------+----------------------------+------------------------------+-------------------+-----------------------------+ | Numba | Release date | Python | NumPy | llvmlite | LLVM | TBB | +===========+==============+===========================+============================+==============================+===================+=============================+ -| 0.57.0 | TBC | 3.8.x <= version < 3.12 | 1.21 <= version < 1.24 | 0.40.x | 11.x | 2021.x | +| 0.57.0 | TBC | 3.8.x <= version < 3.12 | 1.21 <= version < 1.25 | 0.40.x | 11.x | 2021.x | +-----------+--------------+---------------------------+----------------------------+------------------------------+-------------------+-----------------------------+ | 0.56.4 | 2022-11-03 | 3.7.x <= version < 3.11 | 1.18 <= version < 1.24 | 0.39.x | 11.x | 2021.x | +-----------+--------------+---------------------------+----------------------------+------------------------------+-------------------+-----------------------------+ From 1304e64d08cf16f95ba2d6730f164481fc730dd9 Mon Sep 17 00:00:00 2001 From: Graham Markall Date: Wed, 11 Jan 2023 16:25:19 +0000 Subject: [PATCH 15/18] Update comment on skipped test PR #8691 feedback. --- numba/tests/test_comprehension.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/numba/tests/test_comprehension.py b/numba/tests/test_comprehension.py index 092ed51dac4..9327b4ed3a1 100644 --- a/numba/tests/test_comprehension.py +++ b/numba/tests/test_comprehension.py @@ -361,7 +361,9 @@ def comp_nest_with_array_conditional(n): self.check(comp_nest_with_array_conditional, 5, assert_allocate_list=True) - @unittest.skipUnless(numpy_version < (1, 24), 'Removed in NumPy 1.24') + @unittest.skipUnless(numpy_version < (1, 24), + 'Setting an array element with a sequence is removed ' + 'in NumPy 1.24') def test_comp_nest_with_dependency(self): def comp_nest_with_dependency(n): l = np.array([[i * j for j in range(i+1)] for i in range(n)]) From a0a830067f8f864d1f4cb44530999ff0c80c1949 Mon Sep 17 00:00:00 2001 From: Graham Markall Date: Fri, 27 Jan 2023 12:06:57 +0000 Subject: [PATCH 16/18] Correct name of ufunc method in fastcall flags error The name of the method should be given, which was never `at()`. --- numba/np/ufunc/_internal.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/numba/np/ufunc/_internal.c b/numba/np/ufunc/_internal.c index 6d412f9332c..2557c975d60 100644 --- a/numba/np/ufunc/_internal.c +++ b/numba/np/ufunc/_internal.c @@ -363,8 +363,9 @@ init_ufunc_dispatch(int *numpy_uses_fastcall) *numpy_uses_fastcall = crnt->ml_flags & METH_FASTCALL; } else if (*numpy_uses_fastcall != (crnt->ml_flags & METH_FASTCALL)) { - PyErr_SetString(PyExc_RuntimeError, - "ufunc.at() flags do not match numpy_uses_fastcall"); + PyErr_Format(PyExc_RuntimeError, + "ufunc.%s() flags do not match numpy_uses_fastcall", + crnt_name); return -1; } } From 2d0f930be52ca5bee4c18c1bc060bbcd9a36f11c Mon Sep 17 00:00:00 2001 From: Graham Markall Date: Mon, 6 Mar 2023 15:09:04 +0000 Subject: [PATCH 17/18] Use conda-forge for NumPy 1.24 --- buildscripts/incremental/setup_conda_environment.cmd | 6 +++++- buildscripts/incremental/setup_conda_environment.sh | 12 +++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/buildscripts/incremental/setup_conda_environment.cmd b/buildscripts/incremental/setup_conda_environment.cmd index 4518ec38547..4494c2bc388 100644 --- a/buildscripts/incremental/setup_conda_environment.cmd +++ b/buildscripts/incremental/setup_conda_environment.cmd @@ -14,6 +14,10 @@ cmd /C conda info set CONDA_INSTALL=cmd /C conda install -q -y set PIP_INSTALL=pip install -q +@rem Use conda-forge for NumPy 1.24 - at the time of writing it is not available +@rem on the defaults channel. +if %NUMPY%=="1.24" set NUMPY_CHANNEL_PKG="conda-forge::numpy" else set NUMPY_CHANNEL_PKG="numpy" + @echo on @rem Deactivate any environment @@ -21,7 +25,7 @@ call deactivate @rem Display root environment (for debugging) conda list @rem Scipy, CFFI, jinja2 and IPython are optional dependencies, but exercised in the test suite -conda create -n %CONDA_ENV% -q -y python=%PYTHON% numpy=%NUMPY% cffi pip scipy jinja2 ipython gitpython pyyaml +conda create -n %CONDA_ENV% -q -y python=%PYTHON% %NUMPY_CHANNEL_PKG%=%NUMPY% cffi pip scipy jinja2 ipython gitpython pyyaml call activate %CONDA_ENV% @rem Install latest llvmlite build diff --git a/buildscripts/incremental/setup_conda_environment.sh b/buildscripts/incremental/setup_conda_environment.sh index 8a1adf666d5..bc554421b3d 100755 --- a/buildscripts/incremental/setup_conda_environment.sh +++ b/buildscripts/incremental/setup_conda_environment.sh @@ -27,13 +27,23 @@ source deactivate # Display root environment (for debugging) conda list +# Use conda-forge for NumPy 1.24 - at the time of writing it is not available +# on the defaults channel. + +if [ "${NUMPY}" == "1.24" ]; then + NUMPY_CHANNEL_PKG=conda-forge::numpy +else + NUMPY_CHANNEL_PKG=numpy +fi + # If VANILLA_INSTALL is yes, then only Python, NumPy and pip are installed, this # is to catch tests/code paths that require an optional package and are not # guarding against the possibility that it does not exist in the environment. # Create a base env first and then add to it... # NOTE: gitpython is needed for CI testing to do the test slicing # NOTE: pyyaml is used to ensure that the Azure CI config is valid -conda create -n $CONDA_ENV -q -y ${EXTRA_CHANNELS} python=$PYTHON numpy=$NUMPY pip gitpython pyyaml + +conda create -n $CONDA_ENV -q -y ${EXTRA_CHANNELS} python=$PYTHON $NUMPY_CHANNEL_PKG=$NUMPY pip gitpython pyyaml # Activate first set +v From 158033b52838810fbe983ec86ea2016ff4ef2d43 Mon Sep 17 00:00:00 2001 From: Graham Markall Date: Mon, 6 Mar 2023 15:24:43 +0000 Subject: [PATCH 18/18] Attempt to correct syntax for NumPy package channel setting on Windows --- buildscripts/gpuci/build.sh | 11 ++++++++++- buildscripts/incremental/setup_conda_environment.cmd | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/buildscripts/gpuci/build.sh b/buildscripts/gpuci/build.sh index fe9c85eddda..441082f1390 100644 --- a/buildscripts/gpuci/build.sh +++ b/buildscripts/gpuci/build.sh @@ -38,6 +38,15 @@ fi; declare -A CTK_NUMPY_VMAP=( ["11.0"]="1.21" ["11.1"]="1.22" ["11.2"]="1.23" ["11.5"]="1.24" ["11.8"]="1.24") NUMPY_VER="${CTK_NUMPY_VMAP[$CUDA_TOOLKIT_VER]}" +# Use conda-forge for NumPy 1.24 - at the time of writing it is not available +# on the defaults channel. + +if [ "${NUMPY}" == "1.24" ]; then + NUMPY_CHANNEL_PKG=conda-forge::numpy +else + NUMPY_CHANNEL_PKG=numpy +fi + ################################################################################ # SETUP - Check environment @@ -57,7 +66,7 @@ gpuci_mamba_retry create -n numba_ci -y \ "rapidsai::cubinlinker" \ "conda-forge::ptxcompiler" \ "numba/label/dev::llvmlite" \ - "numpy=${NUMPY_VER}" \ + "${NUMPY_CHANNEL_PKG}=${NUMPY_VER}" \ "scipy" \ "cffi" \ "psutil" \ diff --git a/buildscripts/incremental/setup_conda_environment.cmd b/buildscripts/incremental/setup_conda_environment.cmd index 4494c2bc388..c6062a1b014 100644 --- a/buildscripts/incremental/setup_conda_environment.cmd +++ b/buildscripts/incremental/setup_conda_environment.cmd @@ -16,7 +16,7 @@ set PIP_INSTALL=pip install -q @rem Use conda-forge for NumPy 1.24 - at the time of writing it is not available @rem on the defaults channel. -if %NUMPY%=="1.24" set NUMPY_CHANNEL_PKG="conda-forge::numpy" else set NUMPY_CHANNEL_PKG="numpy" +if %NUMPY%==1.24 (set NUMPY_CHANNEL_PKG="conda-forge::numpy") else (set NUMPY_CHANNEL_PKG="numpy") @echo on