Skip to content

Commit 9ffe080

Browse files
authored
Merge pull request #8691 from gmarkall/np-124-review
NumPy 1.24
2 parents 4c1aef5 + 158033b commit 9ffe080

15 files changed

Lines changed: 141 additions & 105 deletions

‎azure-pipelines.yml‎

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ jobs:
1212
name: macOS
1313
vmImage: macos-11
1414
matrix:
15-
py38_np118:
15+
py38_np121:
1616
PYTHON: '3.8'
17-
NUMPY: '1.18'
17+
NUMPY: '1.21'
1818
CONDA_ENV: 'azure_ci'
1919
TEST_START_INDEX: 0
20-
py310_np123:
20+
py310_np124:
2121
PYTHON: '3.10'
22-
NUMPY: '1.23'
22+
NUMPY: '1.24'
2323
CONDA_ENV: 'azure_ci'
2424
TEST_THREADING: 'tbb'
2525
TEST_START_INDEX: 1
@@ -29,89 +29,89 @@ jobs:
2929
name: Linux
3030
vmImage: ubuntu-20.04
3131
matrix:
32-
py38_np118_vanilla:
32+
py38_np121_vanilla:
3333
PYTHON: '3.8'
34-
NUMPY: '1.18'
34+
NUMPY: '1.21'
3535
CONDA_ENV: azure_ci
3636
VANILLA_INSTALL: yes
3737
TEST_START_INDEX: 2
38-
py38_np118_cov:
38+
py38_np121_cov:
3939
PYTHON: '3.8'
40-
NUMPY: '1.18'
40+
NUMPY: '1.21'
4141
CONDA_ENV: azure_ci
4242
RUN_COVERAGE: yes
4343
RUN_FLAKE8: yes
4444
RUN_MYPY: yes
4545
TEST_START_INDEX: 3
46-
py38_np119_tbb:
46+
py38_np122_tbb:
4747
PYTHON: '3.8'
48-
NUMPY: '1.19.2=*_0'
48+
NUMPY: '1.22'
4949
CONDA_ENV: azure_ci
5050
TEST_THREADING: 'tbb'
5151
TEST_START_INDEX: 4
52-
py38_np119_omp:
52+
py38_np122_omp:
5353
PYTHON: '3.8'
54-
NUMPY: '1.19.2=*_0'
54+
NUMPY: '1.22'
5555
CONDA_ENV: azure_ci
5656
TEST_THREADING: omp
5757
TEST_START_INDEX: 5
58-
py38_np119_workqueue:
58+
py38_np122_workqueue:
5959
PYTHON: '3.8'
60-
NUMPY: '1.19.2=*_0'
60+
NUMPY: '1.22'
6161
CONDA_ENV: azure_ci
6262
TEST_THREADING: workqueue
6363
TEST_START_INDEX: 6
64-
py38_np120_doc:
64+
py38_np123_doc:
6565
PYTHON: '3.8'
66-
NUMPY: '1.20'
66+
NUMPY: '1.23'
6767
CONDA_ENV: azure_ci
6868
BUILD_DOC: yes
6969
TEST_START_INDEX: 7
70-
py38_np120:
70+
py38_np122:
7171
PYTHON: '3.8'
72-
NUMPY: '1.20'
72+
NUMPY: '1.22'
7373
CONDA_ENV: azure_ci
7474
TEST_START_INDEX: 8
75-
py38_np120_svml:
75+
py38_np123_svml:
7676
PYTHON: '3.8'
77-
NUMPY: '1.20'
77+
NUMPY: '1.23'
7878
CONDA_ENV: azure_ci
7979
TEST_SVML: yes
8080
TEST_START_INDEX: 9
81-
py38_np122:
81+
py38_np124:
8282
PYTHON: '3.8'
83-
NUMPY: '1.22'
83+
NUMPY: '1.24'
8484
CONDA_ENV: azure_ci
8585
TEST_START_INDEX: 10
86-
py39_np119:
86+
py39_np123:
8787
PYTHON: '3.9'
88-
NUMPY: '1.19.2=*_0'
88+
NUMPY: '1.23'
8989
CONDA_ENV: azure_ci
9090
TEST_START_INDEX: 11
91-
py39_np120_typeguard:
91+
py39_np123_typeguard:
9292
PYTHON: '3.9'
93-
NUMPY: '1.20'
93+
NUMPY: '1.23'
9494
CONDA_ENV: azure_ci
9595
RUN_TYPEGUARD: yes
9696
TEST_START_INDEX: 12
97-
py39_np121:
97+
py39_np122:
9898
PYTHON: '3.9'
99-
NUMPY: '1.21'
99+
NUMPY: '1.22'
100100
CONDA_ENV: azure_ci
101101
TEST_START_INDEX: 13
102-
py39_np123:
102+
py39_np124:
103103
PYTHON: '3.9'
104-
NUMPY: '1.23'
104+
NUMPY: '1.24'
105105
CONDA_ENV: azure_ci
106106
TEST_START_INDEX: 14
107-
py310_np121:
107+
py310_np123:
108108
PYTHON: '3.10'
109-
NUMPY: '1.21'
109+
NUMPY: '1.23'
110110
CONDA_ENV: azure_ci
111111
TEST_START_INDEX: 15
112-
py310_np123:
112+
py310_np124:
113113
PYTHON: '3.10'
114-
NUMPY: '1.23'
114+
NUMPY: '1.24'
115115
CONDA_ENV: azure_ci
116116
TEST_START_INDEX: 16
117117

‎buildscripts/azure/azure-windows.yml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ jobs:
88
vmImage: ${{ parameters.vmImage }}
99
strategy:
1010
matrix:
11-
py310_np123:
11+
py310_np124:
1212
PYTHON: '3.10'
13-
NUMPY: '1.23'
13+
NUMPY: '1.24'
1414
CONDA_ENV: 'testenv'
1515
TEST_START_INDEX: 17
16-
py38_np118:
16+
py38_np121:
1717
PYTHON: '3.8'
18-
NUMPY: '1.18'
18+
NUMPY: '1.21'
1919
CONDA_ENV: 'testenv'
2020
TEST_START_INDEX: 18
2121

‎buildscripts/gpuci/build.sh‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,18 @@ fi;
3535
# Test with different NumPy versions with each toolkit (it's not worth testing
3636
# the Cartesian product of versions here, we just need to test with different
3737
# CUDA and NumPy versions).
38-
declare -A CTK_NUMPY_VMAP=( ["11.0"]="1.19" ["11.1"]="1.20" ["11.2"]="1.21" ["11.5"]="1.22" ["11.8"]="1.23")
38+
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")
3939
NUMPY_VER="${CTK_NUMPY_VMAP[$CUDA_TOOLKIT_VER]}"
4040

41+
# Use conda-forge for NumPy 1.24 - at the time of writing it is not available
42+
# on the defaults channel.
43+
44+
if [ "${NUMPY}" == "1.24" ]; then
45+
NUMPY_CHANNEL_PKG=conda-forge::numpy
46+
else
47+
NUMPY_CHANNEL_PKG=numpy
48+
fi
49+
4150

4251
################################################################################
4352
# SETUP - Check environment
@@ -57,7 +66,7 @@ gpuci_mamba_retry create -n numba_ci -y \
5766
"rapidsai::cubinlinker" \
5867
"conda-forge::ptxcompiler" \
5968
"numba/label/dev::llvmlite" \
60-
"numpy=${NUMPY_VER}" \
69+
"${NUMPY_CHANNEL_PKG}=${NUMPY_VER}" \
6170
"scipy" \
6271
"cffi" \
6372
"psutil" \

‎buildscripts/incremental/setup_conda_environment.cmd‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,18 @@ cmd /C conda info
1414
set CONDA_INSTALL=cmd /C conda install -q -y
1515
set PIP_INSTALL=pip install -q
1616

17+
@rem Use conda-forge for NumPy 1.24 - at the time of writing it is not available
18+
@rem on the defaults channel.
19+
if %NUMPY%==1.24 (set NUMPY_CHANNEL_PKG="conda-forge::numpy") else (set NUMPY_CHANNEL_PKG="numpy")
20+
1721
@echo on
1822

1923
@rem Deactivate any environment
2024
call deactivate
2125
@rem Display root environment (for debugging)
2226
conda list
2327
@rem Scipy, CFFI, jinja2 and IPython are optional dependencies, but exercised in the test suite
24-
conda create -n %CONDA_ENV% -q -y python=%PYTHON% numpy=%NUMPY% cffi pip scipy jinja2 ipython gitpython pyyaml
28+
conda create -n %CONDA_ENV% -q -y python=%PYTHON% %NUMPY_CHANNEL_PKG%=%NUMPY% cffi pip scipy jinja2 ipython gitpython pyyaml
2529

2630
call activate %CONDA_ENV%
2731
@rem Install latest llvmlite build

‎buildscripts/incremental/setup_conda_environment.sh‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,23 @@ source deactivate
2727
# Display root environment (for debugging)
2828
conda list
2929

30+
# Use conda-forge for NumPy 1.24 - at the time of writing it is not available
31+
# on the defaults channel.
32+
33+
if [ "${NUMPY}" == "1.24" ]; then
34+
NUMPY_CHANNEL_PKG=conda-forge::numpy
35+
else
36+
NUMPY_CHANNEL_PKG=numpy
37+
fi
38+
3039
# If VANILLA_INSTALL is yes, then only Python, NumPy and pip are installed, this
3140
# is to catch tests/code paths that require an optional package and are not
3241
# guarding against the possibility that it does not exist in the environment.
3342
# Create a base env first and then add to it...
3443
# NOTE: gitpython is needed for CI testing to do the test slicing
3544
# NOTE: pyyaml is used to ensure that the Azure CI config is valid
36-
conda create -n $CONDA_ENV -q -y ${EXTRA_CHANNELS} python=$PYTHON numpy=$NUMPY pip gitpython pyyaml
45+
46+
conda create -n $CONDA_ENV -q -y ${EXTRA_CHANNELS} python=$PYTHON $NUMPY_CHANNEL_PKG=$NUMPY pip gitpython pyyaml
3747

3848
# Activate first
3949
set +v

‎docs/source/user/installing.rst‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Installation
55
Compatibility
66
-------------
77

8-
Numba is compatible with Python 3.8--3.10, and NumPy versions 1.18 or later.
8+
Numba is compatible with Python 3.8--3.10, and NumPy versions 1.21--1.24.
99

1010
Our supported platforms are:
1111

@@ -260,7 +260,7 @@ information.
260260
+----------++--------------+---------------------------+----------------------------+------------------------------+-------------------+-----------------------------+
261261
| Numba | Release date | Python | NumPy | llvmlite | LLVM | TBB |
262262
+===========+==============+===========================+============================+==============================+===================+=============================+
263-
| 0.57.x | TBC | 3.8.x <= version < 3.12 | 1.19 <= version < 1.24 | 0.40.x | 11.x | 2021.x |
263+
| 0.57.0 | TBC | 3.8.x <= version < 3.12 | 1.21 <= version < 1.25 | 0.40.x | 11.x | 2021.x |
264264
+-----------+--------------+---------------------------+----------------------------+------------------------------+-------------------+-----------------------------+
265265
| 0.56.4 | 2022-11-03 | 3.7.x <= version < 3.11 | 1.18 <= version < 1.24 | 0.39.x | 11.x | 2021.x |
266266
+-----------+--------------+---------------------------+----------------------------+------------------------------+-------------------+-----------------------------+

‎numba/cuda/tests/cudapy/test_intrinsics.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ def test_hmax(self):
833833
arg2 = np.float16(4.)
834834
compiled[1, 1](ary, arg1, arg2)
835835
np.testing.assert_allclose(ary[0], arg2)
836-
arg1 = np.float(5.)
836+
arg1 = np.float16(5.)
837837
compiled[1, 1](ary, arg1, arg2)
838838
np.testing.assert_allclose(ary[0], arg1)
839839

@@ -845,7 +845,7 @@ def test_hmin(self):
845845
arg2 = np.float16(4.)
846846
compiled[1, 1](ary, arg1, arg2)
847847
np.testing.assert_allclose(ary[0], arg1)
848-
arg1 = np.float(5.)
848+
arg1 = np.float16(5.)
849849
compiled[1, 1](ary, arg1, arg2)
850850
np.testing.assert_allclose(ary[0], arg2)
851851

‎numba/np/arraymath.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4028,6 +4028,10 @@ def histogram_impl(a, bins=10, range=None):
40284028
# This module is imported under the compiler lock which should deal with the
40294029
# lack of thread safety in the warning filter.
40304030
def _gen_np_machar():
4031+
# NumPy 1.24 removed np.MachAr
4032+
if numpy_version >= (1, 24):
4033+
return
4034+
40314035
np122plus = numpy_version >= (1, 22)
40324036
w = None
40334037
with warnings.catch_warnings(record=True) as w:

‎numba/np/ufunc/_internal.c‎

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,7 @@ static struct _ufunc_dispatch {
306306
PyCFunctionWithKeywords ufunc_accumulate;
307307
PyCFunctionWithKeywords ufunc_reduceat;
308308
PyCFunctionWithKeywords ufunc_outer;
309-
#if NPY_API_VERSION >= 0x00000008
310309
PyCFunction ufunc_at;
311-
#endif
312310
} ufunc_dispatch;
313311

314312
static int
@@ -324,10 +322,8 @@ init_ufunc_dispatch(int *numpy_uses_fastcall)
324322
if (strncmp(crnt_name, "accumulate", 11) == 0) {
325323
ufunc_dispatch.ufunc_accumulate =
326324
(PyCFunctionWithKeywords)crnt->ml_meth;
327-
#if NPY_API_VERSION >= 0x00000008
328325
} else if (strncmp(crnt_name, "at", 3) == 0) {
329326
ufunc_dispatch.ufunc_at = crnt->ml_meth;
330-
#endif
331327
} else {
332328
result = -1;
333329
}
@@ -347,10 +343,15 @@ init_ufunc_dispatch(int *numpy_uses_fastcall)
347343
} else if (strncmp(crnt_name, "reduceat", 9) == 0) {
348344
ufunc_dispatch.ufunc_reduceat =
349345
(PyCFunctionWithKeywords)crnt->ml_meth;
346+
} else if (strncmp(crnt_name, "resolve_dtypes", 15) == 0) {
347+
/* Ignored */
350348
} else {
351349
result = -1;
352350
}
353351
break;
352+
case '_':
353+
// We ignore private methods
354+
break;
354355
default:
355356
result = -1; /* Unknown method */
356357
}
@@ -362,6 +363,9 @@ init_ufunc_dispatch(int *numpy_uses_fastcall)
362363
*numpy_uses_fastcall = crnt->ml_flags & METH_FASTCALL;
363364
}
364365
else if (*numpy_uses_fastcall != (crnt->ml_flags & METH_FASTCALL)) {
366+
PyErr_Format(PyExc_RuntimeError,
367+
"ufunc.%s() flags do not match numpy_uses_fastcall",
368+
crnt_name);
365369
return -1;
366370
}
367371
}
@@ -372,11 +376,13 @@ init_ufunc_dispatch(int *numpy_uses_fastcall)
372376
&& (ufunc_dispatch.ufunc_accumulate != NULL)
373377
&& (ufunc_dispatch.ufunc_reduceat != NULL)
374378
&& (ufunc_dispatch.ufunc_outer != NULL)
375-
#if NPY_API_VERSION >= 0x00000008
376379
&& (ufunc_dispatch.ufunc_at != NULL)
377-
#endif
378380
);
381+
} else {
382+
char const * const fmt = "Unexpected ufunc method %s()";
383+
PyErr_Format(PyExc_RuntimeError, fmt, crnt_name);
379384
}
385+
380386
return result;
381387
}
382388

@@ -446,13 +452,11 @@ dufunc_outer_fast(PyDUFuncObject * self,
446452
}
447453

448454

449-
#if NPY_API_VERSION >= 0x00000008
450455
static PyObject *
451456
dufunc_at(PyDUFuncObject * self, PyObject * args)
452457
{
453458
return ufunc_dispatch.ufunc_at((PyObject*)self->ufunc, args);
454459
}
455-
#endif
456460

457461
static PyObject *
458462
dufunc__compile_for_args(PyDUFuncObject * self, PyObject * args,
@@ -630,11 +634,9 @@ static struct PyMethodDef dufunc_methods[] = {
630634
{"outer",
631635
(PyCFunction)dufunc_outer,
632636
METH_VARARGS | METH_KEYWORDS, NULL},
633-
#if NPY_API_VERSION >= 0x00000008
634637
{"at",
635638
(PyCFunction)dufunc_at,
636639
METH_VARARGS, NULL},
637-
#endif
638640
{"_compile_for_args",
639641
(PyCFunction)dufunc__compile_for_args,
640642
METH_VARARGS | METH_KEYWORDS,
@@ -664,11 +666,9 @@ static struct PyMethodDef dufunc_methods_fast[] = {
664666
{"outer",
665667
(PyCFunction)dufunc_outer_fast,
666668
METH_FASTCALL | METH_KEYWORDS, NULL},
667-
#if NPY_API_VERSION >= 0x00000008
668669
{"at",
669670
(PyCFunction)dufunc_at,
670671
METH_VARARGS, NULL},
671-
#endif
672672
{"_compile_for_args",
673673
(PyCFunction)dufunc__compile_for_args,
674674
METH_VARARGS | METH_KEYWORDS,
@@ -837,9 +837,7 @@ MOD_INIT(_internal)
837837
if (PyModule_AddIntMacro(m, PyUFunc_One)
838838
|| PyModule_AddIntMacro(m, PyUFunc_Zero)
839839
|| PyModule_AddIntMacro(m, PyUFunc_None)
840-
#if NPY_API_VERSION >= 0x00000007
841840
|| PyModule_AddIntMacro(m, PyUFunc_ReorderableNone)
842-
#endif
843841
)
844842
return MOD_ERROR_VAL;
845843

0 commit comments

Comments
 (0)