File numpy23.patch of Package python-numba
From 7f05bd743a75ec393e55ae36dfeffe064d830bc1 Mon Sep 17 00:00:00 2001
From: Eric Wieser <efw@google.com>
Date: Tue, 15 Jul 2025 17:15:34 +0000
Subject: [PATCH 1/4] Fixes for NumPy 2.3.0
---
.github/workflows/conda_workflow_matrix.json | 3 ++-
.github/workflows/wheel_workflow_matrix.json | 3 ++-
numba/np/arraymath.py | 6 ++++--
numba/tests/test_np_functions.py | 10 ++++++++--
numba/tests/test_types.py | 2 +-
5 files changed, 17 insertions(+), 7 deletions(-)
Index: numba-0.61.2/numba/np/new_arraymath.py
===================================================================
--- numba-0.61.2.orig/numba/np/new_arraymath.py
+++ numba-0.61.2/numba/np/new_arraymath.py
@@ -1887,7 +1887,11 @@ def np_partition(a, kth):
raise NumbaTypeError(msg)
kthdt = getattr(kth, 'dtype', kth)
- if not isinstance(kthdt, (types.Boolean, types.Integer)):
+ if numpy_version >= (2, 3):
+ kth_types = types.Integer
+ else:
+ kth_types = (types.Boolean, types.Integer)
+ if not isinstance(kthdt, kth_types):
# bool gets cast to int subsequently
raise NumbaTypeError('Partition index must be integer')
@@ -1913,7 +1917,11 @@ def np_argpartition(a, kth):
raise NumbaTypeError(msg)
kthdt = getattr(kth, 'dtype', kth)
- if not isinstance(kthdt, (types.Boolean, types.Integer)):
+ if numpy_version >= (2, 3):
+ kth_types = types.Integer
+ else:
+ kth_types = (types.Boolean, types.Integer)
+ if not isinstance(kthdt, kth_types):
# bool gets cast to int subsequently
raise NumbaTypeError('Partition index must be integer')
Index: numba-0.61.2/numba/tests/test_np_functions.py
===================================================================
--- numba-0.61.2.orig/numba/tests/test_np_functions.py
+++ numba-0.61.2/numba/tests/test_np_functions.py
@@ -2934,17 +2934,23 @@ class TestNPFunctions(MemoryLeakMixin, T
def test_partition_boolean_inputs(self):
pyfunc = partition
cfunc = jit(nopython=True)(pyfunc)
+ kths = (-1, 0, 1)
+ if numpy_version < (2, 3):
+ kths = (True, False) + kths
for d in np.linspace(1, 10, 17), np.array((True, False, True)):
- for kth in True, False, -1, 0, 1:
+ for kth in kths:
self.partition_sanity_check(pyfunc, cfunc, d, kth)
def test_argpartition_boolean_inputs(self):
pyfunc = argpartition
cfunc = jit(nopython=True)(pyfunc)
+ kths = (-1, 0, 1)
+ if numpy_version < (2, 3):
+ kths = (True, False) + kths
for d in np.linspace(1, 10, 17), np.array((True, False, True)):
- for kth in True, False, -1, 0, 1:
+ for kth in kths:
self.argpartition_sanity_check(pyfunc, cfunc, d, kth)
@needs_blas
Index: numba-0.61.2/numba/tests/test_types.py
===================================================================
--- numba-0.61.2.orig/numba/tests/test_types.py
+++ numba-0.61.2/numba/tests/test_types.py
@@ -567,7 +567,7 @@ class TestRecordDtype(unittest.TestCase)
art1 = rec_ty[::1]
arr = np.zeros(5, dtype=rec_dt)
art2 = typeof(arr)
- self.assertEqual(art2.dtype.dtype, rec_ty)
+ self.assertEqual(art2.dtype.dtype, rec_ty.dtype)
self.assertEqual(art1, art2)
def test_user_specified(self):
Index: numba-0.61.2/docs/upcoming_changes/10147.highlight.rst
===================================================================
--- /dev/null
+++ numba-0.61.2/docs/upcoming_changes/10147.highlight.rst
@@ -0,0 +1,4 @@
+Support for NumPy 2.3
+---------------------
+
+Numba now supports NumPy 2.3.
Index: numba-0.61.2/setup.py
===================================================================
--- numba-0.61.2.orig/setup.py
+++ numba-0.61.2/setup.py
@@ -23,7 +23,7 @@ min_python_version = "3.10"
max_python_version = "3.14" # exclusive
min_numpy_build_version = "2.0.0rc1"
min_numpy_run_version = "1.24"
-max_numpy_run_version = "2.3"
+max_numpy_run_version = "2.4"
min_llvmlite_version = "0.44.0dev0"
max_llvmlite_version = "0.45"
Index: numba-0.61.2/numba/__init__.py
===================================================================
--- numba-0.61.2.orig/numba/__init__.py
+++ numba-0.61.2/numba/__init__.py
@@ -39,8 +39,8 @@ def _ensure_critical_deps():
f"{numpy_version[0]}.{numpy_version[1]}.")
raise ImportError(msg)
- if numpy_version > (2, 2):
- msg = (f"Numba needs NumPy 2.2 or less. Got NumPy "
+ if numpy_version > (2, 3):
+ msg = (f"Numba needs NumPy 2.3 or less. Got NumPy "
f"{numpy_version[0]}.{numpy_version[1]}.")
raise ImportError(msg)