1From c3e6994e07fb6ac57be5d9d33d9046c5453b2256 Mon Sep 17 00:00:00 2001
2From: Graham Markall <gmarkall@nvidia.com>
3Date: Thu, 24 Nov 2022 15:41:24 +0000
4Subject: [PATCH 01/13] CUDA intrinsics tests: correct np.float -> np.float16
5
6I believe this was written in error and should always have been float16.
7---
8 numba/cuda/tests/cudapy/test_intrinsics.py | 4 ++--
9 1 file changed, 2 insertions(+), 2 deletions(-)
10
11diff --git a/numba/cuda/tests/cudapy/test_intrinsics.py b/numba/cuda/tests/cudapy/test_intrinsics.py
12index 6e5fc0a0e..46fe8c607 100644
13--- a/numba/cuda/tests/cudapy/test_intrinsics.py
14+++ b/numba/cuda/tests/cudapy/test_intrinsics.py
15@@ -619,7 +619,7 @@ class TestCudaIntrinsic(CUDATestCase):
16 arg2 = np.float16(4.)
17 compiled[1, 1](ary, arg1, arg2)
18 np.testing.assert_allclose(ary[0], arg2)
19- arg1 = np.float(5.)
20+ arg1 = np.float16(5.)
21 compiled[1, 1](ary, arg1, arg2)
22 np.testing.assert_allclose(ary[0], arg1)
23
24@@ -631,7 +631,7 @@ class TestCudaIntrinsic(CUDATestCase):
25 arg2 = np.float16(4.)
26 compiled[1, 1](ary, arg1, arg2)
27 np.testing.assert_allclose(ary[0], arg1)
28- arg1 = np.float(5.)
29+ arg1 = np.float16(5.)
30 compiled[1, 1](ary, arg1, arg2)
31 np.testing.assert_allclose(ary[0], arg2)
32
33--
342.39.1
35
36From 550fc6a25a82f76bc1f06bdea39177df635038c2 Mon Sep 17 00:00:00 2001
37From: Graham Markall <gmarkall@nvidia.com>
38Date: Thu, 22 Dec 2022 13:02:22 +0000
39Subject: [PATCH 02/13] TestLinalgSvd.test_no_input_mutation: use
40 reconstruction if necessary
41
42This test only checked for a plain match when comparing outputs.
43However, in some cases a reconstruction check can be necessary, as in
44`test_linalg_svd`.
45---
46 numba/tests/test_linalg.py | 61 ++++++++++++++++++++------------------
47 1 file changed, 32 insertions(+), 29 deletions(-)
48
49diff --git a/numba/tests/test_linalg.py b/numba/tests/test_linalg.py
50index db183059d..b1d4f0a83 100644
51--- a/numba/tests/test_linalg.py
52+++ b/numba/tests/test_linalg.py
53@@ -1122,6 +1122,32 @@ class TestLinalgSvd(TestLinalgBase):
54 Tests for np.linalg.svd.
55 """
56
57+ # This checks that A ~= U*S*V**H, i.e. SV decomposition ties out. This is
58+ # required as NumPy uses only double precision LAPACK routines and
59+ # computation of SVD is numerically sensitive. Numba uses type-specific
60+ # routines and therefore sometimes comes out with a different answer to
61+ # NumPy (orthonormal bases are not unique, etc.).
62+
63+ def check_reconstruction(self, a, got, expected):
64+ u, sv, vt = got
65+
66+ # Check they are dimensionally correct
67+ for k in range(len(expected)):
68+ self.assertEqual(got[k].shape, expected[k].shape)
69+
70+ # Columns in u and rows in vt dictates the working size of s
71+ s = np.zeros((u.shape[1], vt.shape[0]))
72+ np.fill_diagonal(s, sv)
73+
74+ rec = np.dot(np.dot(u, s), vt)
75+ resolution = np.finfo(a.dtype).resolution
76+ np.testing.assert_allclose(
77+ a,
78+ rec,
79+ rtol=10 * resolution,
80+ atol=100 * resolution # zeros tend to be fuzzy
81+ )
82+
83 @needs_lapack
84 def test_linalg_svd(self):
85 """
86@@ -1150,34 +1176,8 @@ class TestLinalgSvd(TestLinalgBase):
87 # plain match failed, test by reconstruction
88 use_reconstruction = True
89
90- # if plain match fails then reconstruction is used.
91- # this checks that A ~= U*S*V**H
92- # i.e. SV decomposition ties out
93- # this is required as numpy uses only double precision lapack
94- # routines and computation of svd is numerically
95- # sensitive, numba using the type specific routines therefore
96- # sometimes comes out with a different answer (orthonormal bases
97- # are not unique etc.).
98 if use_reconstruction:
99- u, sv, vt = got
100-
101- # check they are dimensionally correct
102- for k in range(len(expected)):
103- self.assertEqual(got[k].shape, expected[k].shape)
104-
105- # regardless of full_matrices cols in u and rows in vt
106- # dictates the working size of s
107- s = np.zeros((u.shape[1], vt.shape[0]))
108- np.fill_diagonal(s, sv)
109-
110- rec = np.dot(np.dot(u, s), vt)
111- resolution = np.finfo(a.dtype).resolution
112- np.testing.assert_allclose(
113- a,
114- rec,
115- rtol=10 * resolution,
116- atol=100 * resolution # zeros tend to be fuzzy
117- )
118+ self.check_reconstruction(a, got, expected)
119
120 # Ensure proper resource management
121 with self.assertNoNRTLeak():
122@@ -1238,8 +1238,11 @@ class TestLinalgSvd(TestLinalgBase):
123 got = func(X, False)
124 np.testing.assert_allclose(X, X_orig)
125
126- for e_a, g_a in zip(expected, got):
127- np.testing.assert_allclose(e_a, g_a)
128+ try:
129+ for e_a, g_a in zip(expected, got):
130+ np.testing.assert_allclose(e_a, g_a)
131+ except AssertionError:
132+ self.check_reconstruction(X, got, expected)
133
134
135 class TestLinalgQr(TestLinalgBase):
136--
1372.39.1
138
139From c9ca2d1ae5e09ace729cddf6fba08effcd69a0b7 Mon Sep 17 00:00:00 2001
140From: Graham Markall <gmarkall@nvidia.com>
141Date: Thu, 24 Nov 2022 21:39:27 +0000
142Subject: [PATCH 03/13] test_comp_nest_with_dependency: skip on NumPy 1.24
143
144Setting an array element with a sequence is removed in NumPy 1.24.
145---
146 numba/tests/test_comprehension.py | 2 ++
147 1 file changed, 2 insertions(+)
148
149diff --git a/numba/tests/test_comprehension.py b/numba/tests/test_comprehension.py
150index 2cdd3dc25..092ed51da 100644
151--- a/numba/tests/test_comprehension.py
152+++ b/numba/tests/test_comprehension.py
153@@ -11,6 +11,7 @@ from numba import jit, typed
154 from numba.core import types, utils
155 from numba.core.errors import TypingError, LoweringError
156 from numba.core.types.functions import _header_lead
157+from numba.np.numpy_support import numpy_version
158 from numba.tests.support import tag, _32bit, captured_stdout
159
160
161@@ -360,6 +361,7 @@ class TestArrayComprehension(unittest.TestCase):
162 self.check(comp_nest_with_array_conditional, 5,
163 assert_allocate_list=True)
164
165+ @unittest.skipUnless(numpy_version < (1, 24), 'Removed in NumPy 1.24')
166 def test_comp_nest_with_dependency(self):
167 def comp_nest_with_dependency(n):
168 l = np.array([[i * j for j in range(i+1)] for i in range(n)])
169--
1702.39.1
171
172From e69ad519352ac5a1f7714083968fcbac3ba92f95 Mon Sep 17 00:00:00 2001
173From: Graham Markall <gmarkall@nvidia.com>
174Date: Thu, 24 Nov 2022 16:48:37 +0000
175Subject: [PATCH 04/13] Avoid use of np.bool in stencilparfor.py
176
177---
178 numba/stencils/stencilparfor.py | 7 ++++++-
179 1 file changed, 6 insertions(+), 1 deletion(-)
180
181diff --git a/numba/stencils/stencilparfor.py b/numba/stencils/stencilparfor.py
182index 5f30893b3..4f23ed903 100644
183--- a/numba/stencils/stencilparfor.py
184+++ b/numba/stencils/stencilparfor.py
185@@ -21,6 +21,7 @@ from numba.core.ir_utils import (get_call_table, mk_unique_var,
186 find_callname, require, find_const, GuardException)
187 from numba.core.errors import NumbaValueError
188 from numba.core.utils import OPERATORS_TO_BUILTINS
189+from numba.np import numpy_support
190
191
192 def _compute_last_ind(dim_size, index_const):
193@@ -264,7 +265,11 @@ class StencilPass(object):
194 dtype_g_np_assign = ir.Assign(dtype_g_np, dtype_g_np_var, loc)
195 init_block.body.append(dtype_g_np_assign)
196
197- dtype_np_attr_call = ir.Expr.getattr(dtype_g_np_var, return_type.dtype.name, loc)
198+ return_type_name = numpy_support.as_dtype(
199+ return_type.dtype).type.__name__
200+ if return_type_name == 'bool':
201+ return_type_name = 'bool_'
202+ dtype_np_attr_call = ir.Expr.getattr(dtype_g_np_var, return_type_name, loc)
203 dtype_attr_var = ir.Var(scope, mk_unique_var("$np_attr_attr"), loc)
204 self.typemap[dtype_attr_var.name] = types.functions.NumberClass(return_type.dtype)
205 dtype_attr_assign = ir.Assign(dtype_np_attr_call, dtype_attr_var, loc)
206--
2072.39.1
208
209From dd96d5996abd8646443501f2bbd7d4e1a9c0eec4 Mon Sep 17 00:00:00 2001
210From: Graham Markall <gmarkall@nvidia.com>
211Date: Thu, 24 Nov 2022 15:46:52 +0000
212Subject: [PATCH 05/13] test_hypot: Tweak regex so it matches NumPy 1.24
213
214The modified regex matches the existing message produced by NumPy <
2151.24, and the new improved message in 1.24.
216---
217 numba/tests/test_mathlib.py | 2 +-
218 1 file changed, 1 insertion(+), 1 deletion(-)
219
220diff --git a/numba/tests/test_mathlib.py b/numba/tests/test_mathlib.py
221index a3f535316..05e3d68f5 100644
222--- a/numba/tests/test_mathlib.py
223+++ b/numba/tests/test_mathlib.py
224@@ -516,7 +516,7 @@ class TestMathLib(TestCase):
225 with warnings.catch_warnings():
226 warnings.simplefilter("error", RuntimeWarning)
227 self.assertRaisesRegexp(RuntimeWarning,
228- 'overflow encountered in .*_scalars',
229+ 'overflow encountered in .*scalar',
230 naive_hypot, val, val)
231
232 def test_hypot_npm(self):
233--
2342.39.1
235
236From b755c22caeec9e6b0e0606f0cee245648914d592 Mon Sep 17 00:00:00 2001
237From: Graham Markall <gmarkall@nvidia.com>
238Date: Thu, 24 Nov 2022 11:29:53 +0000
239Subject: [PATCH 06/13] Don't test summing with timedelta dtype
240
241This always produced invalid results (though they were consistent
242between Numba and NumPy) but now this fails in NumPy 1.24 with an
243exception:
244
245```
246TypeError: The `dtype` and `signature` arguments to ufuncs only select
247the general DType and not details such as the byte order or time unit.
248You can avoid this error by using the scalar types `np.float64` or the
249dtype string notation.
250```
251
252Note that the exception message is misleading, and using the dtype
253string notation does not provide a workaround.
254---
255 numba/tests/test_array_methods.py | 15 ++++++---------
256 1 file changed, 6 insertions(+), 9 deletions(-)
257
258diff --git a/numba/tests/test_array_methods.py b/numba/tests/test_array_methods.py
259index eee5cfeff..a2312adba 100644
260--- a/numba/tests/test_array_methods.py
261+++ b/numba/tests/test_array_methods.py
262@@ -1193,7 +1193,7 @@ class TestArrayMethods(MemoryLeakMixin, TestCase):
263 pyfunc = array_sum_dtype_kws
264 cfunc = jit(nopython=True)(pyfunc)
265 all_dtypes = [np.float64, np.float32, np.int64, np.int32, np.uint32,
266- np.uint64, np.complex64, np.complex128, TIMEDELTA_M]
267+ np.uint64, np.complex64, np.complex128]
268 all_test_arrays = [
269 [np.ones((7, 6, 5, 4, 3), arr_dtype),
270 np.ones(1, arr_dtype),
271@@ -1207,8 +1207,7 @@ class TestArrayMethods(MemoryLeakMixin, TestCase):
272 np.dtype('uint32'): [np.float64, np.int64, np.float32],
273 np.dtype('uint64'): [np.float64, np.int64],
274 np.dtype('complex64'): [np.complex64, np.complex128],
275- np.dtype('complex128'): [np.complex128],
276- np.dtype(TIMEDELTA_M): [np.dtype(TIMEDELTA_M)]}
277+ np.dtype('complex128'): [np.complex128]}
278
279 for arr_list in all_test_arrays:
280 for arr in arr_list:
281@@ -1216,15 +1215,15 @@ class TestArrayMethods(MemoryLeakMixin, TestCase):
282 subtest_str = ("Testing np.sum with {} input and {} output"
283 .format(arr.dtype, out_dtype))
284 with self.subTest(subtest_str):
285- self.assertPreciseEqual(pyfunc(arr, dtype=out_dtype),
286- cfunc(arr, dtype=out_dtype))
287+ self.assertPreciseEqual(pyfunc(arr, dtype=out_dtype),
288+ cfunc(arr, dtype=out_dtype))
289
290 def test_sum_axis_dtype_kws(self):
291 """ test sum with axis and dtype parameters over a whole range of dtypes """
292 pyfunc = array_sum_axis_dtype_kws
293 cfunc = jit(nopython=True)(pyfunc)
294 all_dtypes = [np.float64, np.float32, np.int64, np.int32, np.uint32,
295- np.uint64, np.complex64, np.complex128, TIMEDELTA_M]
296+ np.uint64, np.complex64, np.complex128]
297 all_test_arrays = [
298 [np.ones((7, 6, 5, 4, 3), arr_dtype),
299 np.ones(1, arr_dtype),
300@@ -1238,9 +1237,7 @@ class TestArrayMethods(MemoryLeakMixin, TestCase):
301 np.dtype('uint32'): [np.float64, np.int64, np.float32],
302 np.dtype('uint64'): [np.float64, np.uint64],
303 np.dtype('complex64'): [np.complex64, np.complex128],
304- np.dtype('complex128'): [np.complex128],
305- np.dtype(TIMEDELTA_M): [np.dtype(TIMEDELTA_M)],
306- np.dtype(TIMEDELTA_Y): [np.dtype(TIMEDELTA_Y)]}
307+ np.dtype('complex128'): [np.complex128]}
308
309 for arr_list in all_test_arrays:
310 for arr in arr_list:
311--
3122.39.1
313
314From 65df00379df1276b7045b44818347a119bb32361 Mon Sep 17 00:00:00 2001
315From: Graham Markall <gmarkall@nvidia.com>
316Date: Thu, 24 Nov 2022 10:03:54 +0000
317Subject: [PATCH 07/13] Replace use of deprecated np.bool with np.bool_
318
319np.bool was removed in NumPy 1.24.
320---
321 numba/tests/test_np_functions.py | 8 ++++----
322 1 file changed, 4 insertions(+), 4 deletions(-)
323
324diff --git a/numba/tests/test_np_functions.py b/numba/tests/test_np_functions.py
325index 4cdaf548b..e195ac781 100644
326--- a/numba/tests/test_np_functions.py
327+++ b/numba/tests/test_np_functions.py
328@@ -932,11 +932,11 @@ class TestNPFunctions(MemoryLeakMixin, TestCase):
329 yield np.inf, None
330 yield np.PINF, None
331 yield np.asarray([-np.inf, 0., np.inf]), None
332- yield np.NINF, np.zeros(1, dtype=np.bool)
333- yield np.inf, np.zeros(1, dtype=np.bool)
334- yield np.PINF, np.zeros(1, dtype=np.bool)
335+ yield np.NINF, np.zeros(1, dtype=np.bool_)
336+ yield np.inf, np.zeros(1, dtype=np.bool_)
337+ yield np.PINF, np.zeros(1, dtype=np.bool_)
338 yield np.NINF, np.empty(12)
339- yield np.asarray([-np.inf, 0., np.inf]), np.zeros(3, dtype=np.bool)
340+ yield np.asarray([-np.inf, 0., np.inf]), np.zeros(3, dtype=np.bool_)
341
342 pyfuncs = [isneginf, isposinf]
343 for pyfunc in pyfuncs:
344--
3452.39.1
346
347From 065475bd8d5f39ad0a2b0d154ca283dec10bf5d0 Mon Sep 17 00:00:00 2001
348From: Graham Markall <gmarkall@nvidia.com>
349Date: Thu, 24 Nov 2022 09:56:06 +0000
350Subject: [PATCH 08/13] Overload np.MachAr only for NumPy < 1.24
351
352---
353 numba/np/arraymath.py | 4 ++++
354 numba/tests/test_np_functions.py | 4 +++-
355 2 files changed, 7 insertions(+), 1 deletion(-)
356
357diff --git a/numba/np/arraymath.py b/numba/np/arraymath.py
358index 9885526ee..f6e5f5560 100644
359--- a/numba/np/arraymath.py
360+++ b/numba/np/arraymath.py
361@@ -4177,6 +4177,10 @@ iinfo = namedtuple('iinfo', _iinfo_supported)
362 # This module is imported under the compiler lock which should deal with the
363 # lack of thread safety in the warning filter.
364 def _gen_np_machar():
365+ # NumPy 1.24 removed np.MachAr
366+ if numpy_version >= (1, 24):
367+ return
368+
369 np122plus = numpy_version >= (1, 22)
370 w = None
371 with warnings.catch_warnings(record=True) as w:
372diff --git a/numba/tests/test_np_functions.py b/numba/tests/test_np_functions.py
373index e195ac781..e8a9bccd0 100644
374--- a/numba/tests/test_np_functions.py
375+++ b/numba/tests/test_np_functions.py
376@@ -4775,6 +4775,7 @@ def foo():
377 eval(compile(funcstr, '<string>', 'exec'))
378 return locals()['foo']
379
380+ @unittest.skipIf(numpy_version >= (1, 24), "NumPy < 1.24 required")
381 def test_MachAr(self):
382 attrs = ('ibeta', 'it', 'machep', 'eps', 'negep', 'epsneg', 'iexp',
383 'minexp', 'xmin', 'maxexp', 'xmax', 'irnd', 'ngrd',
384@@ -4817,7 +4818,8 @@ def foo():
385 cfunc = jit(nopython=True)(iinfo)
386 cfunc(np.float64(7))
387
388- @unittest.skipUnless(numpy_version >= (1, 22), "Needs NumPy >= 1.22")
389+ @unittest.skipUnless((1, 22) <= numpy_version < (1, 24),
390+ "Needs NumPy >= 1.22, < 1.24")
391 @TestCase.run_test_in_subprocess
392 def test_np_MachAr_deprecation_np122(self):
393 # Tests that Numba is replaying the NumPy 1.22 deprecation warning
394--
3952.39.1
396
397From 4925287144b9dca5624886ac44a27831178a7198 Mon Sep 17 00:00:00 2001
398From: Graham Markall <gmarkall@nvidia.com>
399Date: Fri, 25 Nov 2022 10:55:04 +0000
400Subject: [PATCH 09/13] _internal.c: Remove NPY_API_VERSION checks
401
402The API version has long since been greater than 0x7 / 0x8 for any
403supported NumPy.
404---
405 numba/np/ufunc/_internal.c | 14 --------------
406 1 file changed, 14 deletions(-)
407
408diff --git a/numba/np/ufunc/_internal.c b/numba/np/ufunc/_internal.c
409index 98a643788..3ab725f8f 100644
410--- a/numba/np/ufunc/_internal.c
411+++ b/numba/np/ufunc/_internal.c
412@@ -285,9 +285,7 @@ static struct _ufunc_dispatch {
413 PyCFunctionWithKeywords ufunc_accumulate;
414 PyCFunctionWithKeywords ufunc_reduceat;
415 PyCFunctionWithKeywords ufunc_outer;
416-#if NPY_API_VERSION >= 0x00000008
417 PyCFunction ufunc_at;
418-#endif
419 } ufunc_dispatch;
420
421 static int
422@@ -303,10 +301,8 @@ init_ufunc_dispatch(int *numpy_uses_fastcall)
423 if (strncmp(crnt_name, "accumulate", 11) == 0) {
424 ufunc_dispatch.ufunc_accumulate =
425 (PyCFunctionWithKeywords)crnt->ml_meth;
426-#if NPY_API_VERSION >= 0x00000008
427 } else if (strncmp(crnt_name, "at", 3) == 0) {
428 ufunc_dispatch.ufunc_at = crnt->ml_meth;
429-#endif
430 } else {
431 result = -1;
432 }
433@@ -351,9 +347,7 @@ init_ufunc_dispatch(int *numpy_uses_fastcall)
434 && (ufunc_dispatch.ufunc_accumulate != NULL)
435 && (ufunc_dispatch.ufunc_reduceat != NULL)
436 && (ufunc_dispatch.ufunc_outer != NULL)
437-#if NPY_API_VERSION >= 0x00000008
438 && (ufunc_dispatch.ufunc_at != NULL)
439-#endif
440 );
441 }
442 return result;
443@@ -425,13 +419,11 @@ dufunc_outer_fast(PyDUFuncObject * self,
444 }
445
446
447-#if NPY_API_VERSION >= 0x00000008
448 static PyObject *
449 dufunc_at(PyDUFuncObject * self, PyObject * args)
450 {
451 return ufunc_dispatch.ufunc_at((PyObject*)self->ufunc, args);
452 }
453-#endif
454
455 static PyObject *
456 dufunc__compile_for_args(PyDUFuncObject * self, PyObject * args,
457@@ -609,11 +601,9 @@ static struct PyMethodDef dufunc_methods[] = {
458 {"outer",
459 (PyCFunction)dufunc_outer,
460 METH_VARARGS | METH_KEYWORDS, NULL},
461-#if NPY_API_VERSION >= 0x00000008
462 {"at",
463 (PyCFunction)dufunc_at,
464 METH_VARARGS, NULL},
465-#endif
466 {"_compile_for_args",
467 (PyCFunction)dufunc__compile_for_args,
468 METH_VARARGS | METH_KEYWORDS,
469@@ -643,11 +633,9 @@ static struct PyMethodDef dufunc_methods_fast[] = {
470 {"outer",
471 (PyCFunction)dufunc_outer_fast,
472 METH_FASTCALL | METH_KEYWORDS, NULL},
473-#if NPY_API_VERSION >= 0x00000008
474 {"at",
475 (PyCFunction)dufunc_at,
476 METH_VARARGS, NULL},
477-#endif
478 {"_compile_for_args",
479 (PyCFunction)dufunc__compile_for_args,
480 METH_VARARGS | METH_KEYWORDS,
481@@ -791,9 +779,7 @@ MOD_INIT(_internal)
482 if (PyModule_AddIntMacro(m, PyUFunc_One)
483 || PyModule_AddIntMacro(m, PyUFunc_Zero)
484 || PyModule_AddIntMacro(m, PyUFunc_None)
485-#if NPY_API_VERSION >= 0x00000007
486 || PyModule_AddIntMacro(m, PyUFunc_ReorderableNone)
487-#endif
488 )
489 return MOD_ERROR_VAL;
490
491--
4922.39.1
493
494From 783ef5a297f15d16eec61fe38d13648b876e3750 Mon Sep 17 00:00:00 2001
495From: Graham Markall <gmarkall@nvidia.com>
496Date: Tue, 3 Jan 2023 17:08:44 +0000
497Subject: [PATCH 10/13] init_ufunc_dispatch: Handle unexpected ufunc methods
498 gracefully
499
500If an unexpected ufunc method was encountered, `init_ufunc_dispatch()`
501would return an error code indicating failure without setting an
502exception, leading to errors like
503
504```
505SystemError: initialization of _internal failed without raising an
506exception
507```
508
509as reported in Issue #8615.
510
511This commit fixes the issue by setting an appropriate exception in this
512case.
513---
514 numba/np/ufunc/_internal.c | 6 ++++++
515 1 file changed, 6 insertions(+)
516
517diff --git a/numba/np/ufunc/_internal.c b/numba/np/ufunc/_internal.c
518index 3ab725f8f..6ce8989cd 100644
519--- a/numba/np/ufunc/_internal.c
520+++ b/numba/np/ufunc/_internal.c
521@@ -337,6 +337,8 @@ init_ufunc_dispatch(int *numpy_uses_fastcall)
522 *numpy_uses_fastcall = crnt->ml_flags & METH_FASTCALL;
523 }
524 else if (*numpy_uses_fastcall != (crnt->ml_flags & METH_FASTCALL)) {
525+ PyErr_SetString(PyExc_RuntimeError,
526+ "ufunc.at() flags do not match numpy_uses_fastcall");
527 return -1;
528 }
529 }
530@@ -349,7 +351,11 @@ init_ufunc_dispatch(int *numpy_uses_fastcall)
531 && (ufunc_dispatch.ufunc_outer != NULL)
532 && (ufunc_dispatch.ufunc_at != NULL)
533 );
534+ } else {
535+ char const * const fmt = "Unexpected ufunc method %s()";
536+ PyErr_Format(PyExc_RuntimeError, fmt, crnt_name);
537 }
538+
539 return result;
540 }
541
542--
5432.39.1
544
545From 5c259e46a8e510c2b82c7ff449b167d3b430294b Mon Sep 17 00:00:00 2001
546From: Graham Markall <gmarkall@nvidia.com>
547Date: Tue, 3 Jan 2023 17:11:10 +0000
548Subject: [PATCH 11/13] init_ufunc_dispatch: Update for NumPy 1.24
549
550NumPy 1.24 adds a new method, `resolve_dtypes()`, and a private method
551`_resolve_dtypes_and_context()`. We handle these by just ignoring them
552(ignoring all private methods in general) in order to provide the same
553level of functionality in Numba as for NumPy 1.23.
554
555There is further room to build new functionality on top of this:
556
557- Providing an implementation of `resolve_dtypes()` for `DUFunc`
558 objects.
559- Using the `resolve_dtypes()` method in place of logic in Numba that
560 implements a similar dtype resolution process.
561---
562 numba/np/ufunc/_internal.c | 5 +++++
563 1 file changed, 5 insertions(+)
564
565diff --git a/numba/np/ufunc/_internal.c b/numba/np/ufunc/_internal.c
566index 6ce8989cd..e860081fb 100644
567--- a/numba/np/ufunc/_internal.c
568+++ b/numba/np/ufunc/_internal.c
569@@ -322,10 +322,15 @@ init_ufunc_dispatch(int *numpy_uses_fastcall)
570 } else if (strncmp(crnt_name, "reduceat", 9) == 0) {
571 ufunc_dispatch.ufunc_reduceat =
572 (PyCFunctionWithKeywords)crnt->ml_meth;
573+ } else if (strncmp(crnt_name, "resolve_dtypes", 15) == 0) {
574+ /* Ignored */
575 } else {
576 result = -1;
577 }
578 break;
579+ case '_':
580+ // We ignore private methods
581+ break;
582 default:
583 result = -1; /* Unknown method */
584 }
585--
5862.39.1
587
588From 3736714982be943eb94f4a259368b1dce525ea64 Mon Sep 17 00:00:00 2001
589From: Graham Markall <gmarkall@nvidia.com>
590Date: Wed, 11 Jan 2023 16:25:19 +0000
591Subject: [PATCH 12/13] Update comment on skipped test
592
593PR #8691 feedback.
594---
595 numba/tests/test_comprehension.py | 4 +++-
596 1 file changed, 3 insertions(+), 1 deletion(-)
597
598diff --git a/numba/tests/test_comprehension.py b/numba/tests/test_comprehension.py
599index 092ed51da..9327b4ed3 100644
600--- a/numba/tests/test_comprehension.py
601+++ b/numba/tests/test_comprehension.py
602@@ -361,7 +361,9 @@ class TestArrayComprehension(unittest.TestCase):
603 self.check(comp_nest_with_array_conditional, 5,
604 assert_allocate_list=True)
605
606- @unittest.skipUnless(numpy_version < (1, 24), 'Removed in NumPy 1.24')
607+ @unittest.skipUnless(numpy_version < (1, 24),
608+ 'Setting an array element with a sequence is removed '
609+ 'in NumPy 1.24')
610 def test_comp_nest_with_dependency(self):
611 def comp_nest_with_dependency(n):
612 l = np.array([[i * j for j in range(i+1)] for i in range(n)])
613--
6142.39.1
615
616From 3cbab7ee436e3452e7d078f8283136671a36d944 Mon Sep 17 00:00:00 2001
617From: Graham Markall <gmarkall@nvidia.com>
618Date: Fri, 27 Jan 2023 12:06:57 +0000
619Subject: [PATCH 13/13] Correct name of ufunc method in fastcall flags error
620
621The name of the method should be given, which was never `at()`.
622---
623 numba/np/ufunc/_internal.c | 5 +++--
624 1 file changed, 3 insertions(+), 2 deletions(-)
625
626diff --git a/numba/np/ufunc/_internal.c b/numba/np/ufunc/_internal.c
627index e860081fb..0a33de170 100644
628--- a/numba/np/ufunc/_internal.c
629+++ b/numba/np/ufunc/_internal.c
630@@ -342,8 +342,9 @@ init_ufunc_dispatch(int *numpy_uses_fastcall)
631 *numpy_uses_fastcall = crnt->ml_flags & METH_FASTCALL;
632 }
633 else if (*numpy_uses_fastcall != (crnt->ml_flags & METH_FASTCALL)) {
634- PyErr_SetString(PyExc_RuntimeError,
635- "ufunc.at() flags do not match numpy_uses_fastcall");
636+ PyErr_Format(PyExc_RuntimeError,
637+ "ufunc.%s() flags do not match numpy_uses_fastcall",
638+ crnt_name);
639 return -1;
640 }
641 }
642--
6432.39.1
644