Skip to content

Commit 7f715fb

Browse files
committed
ENH: Updgrade Array API version to 2024.12
1 parent 295e2d5 commit 7f715fb

File tree

7 files changed

+45
-11
lines changed

7 files changed

+45
-11
lines changed

.github/workflows/linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ jobs:
287287
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
288288
with:
289289
repository: data-apis/array-api-tests
290-
ref: '827edd804bcace9d64176b8115138d29ae3e8dec' # Latest commit as of 2024-07-30
290+
ref: 'c48410f96fc58e02eea844e6b7f6cc01680f77ce' # Latest commit as of 2025-04-01
291291
submodules: 'true'
292292
path: 'array-api-tests'
293293
persist-credentials: false

numpy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@
289289
# import with `from numpy import *`.
290290
__future_scalars__ = {"str", "bytes", "object"}
291291

292-
__array_api_version__ = "2023.12"
292+
__array_api_version__ = "2024.12"
293293

294294
from ._array_api_info import __array_namespace_info__
295295

numpy/__init__.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,7 @@ _DTypeNum: TypeAlias = L[
978978
]
979979
_DTypeBuiltinKind: TypeAlias = L[0, 1, 2]
980980

981-
_ArrayAPIVersion: TypeAlias = L["2021.12", "2022.12", "2023.12"]
981+
_ArrayAPIVersion: TypeAlias = L["2021.12", "2022.12", "2023.12", "2024.12"]
982982

983983
_CastingKind: TypeAlias = L["no", "equiv", "safe", "same_kind", "unsafe"]
984984

@@ -1193,7 +1193,7 @@ __NUMPY_SETUP__: Final[L[False]] = False
11931193
__numpy_submodules__: Final[set[LiteralString]] = ...
11941194
__former_attrs__: Final[_FormerAttrsDict] = ...
11951195
__future_scalars__: Final[set[L["bytes", "str", "object"]]] = ...
1196-
__array_api_version__: Final[L["2023.12"]] = "2023.12"
1196+
__array_api_version__: Final[L["2024.12"]] = "2024.12"
11971197
test: Final[PytestTester] = ...
11981198

11991199
@type_check_only

numpy/_core/src/multiarray/array_api_standard.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ array_array_namespace(PyObject *NPY_UNUSED(self), PyObject *args, PyObject *kwds
6060
return NULL;
6161
} else if (PyUnicode_CompareWithASCIIString(array_api_version, "2021.12") != 0 &&
6262
PyUnicode_CompareWithASCIIString(array_api_version, "2022.12") != 0 &&
63-
PyUnicode_CompareWithASCIIString(array_api_version, "2023.12") != 0)
63+
PyUnicode_CompareWithASCIIString(array_api_version, "2023.12") != 0 &&
64+
PyUnicode_CompareWithASCIIString(array_api_version, "2024.12") != 0)
6465
{
6566
PyErr_Format(PyExc_ValueError,
6667
"Version \"%U\" of the Array API Standard is not supported.",

numpy/_core/src/multiarray/multiarraymodule.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2274,14 +2274,18 @@ array_count_nonzero(PyObject *NPY_UNUSED(self), PyObject *const *args, Py_ssize_
22742274
return NULL;
22752275
}
22762276

2277-
count = PyArray_CountNonzero(array);
2278-
2277+
count = PyArray_CountNonzero(array);
22792278
Py_DECREF(array);
22802279

22812280
if (count == -1) {
22822281
return NULL;
22832282
}
2284-
return PyLong_FromSsize_t(count);
2283+
2284+
PyArray_Descr *descr = PyArray_DescrFromType(NPY_INTP);
2285+
if (descr == NULL) {
2286+
return NULL;
2287+
}
2288+
return PyArray_Scalar(&count, descr, NULL);
22852289
}
22862290

22872291
static PyObject *

numpy/_core/tests/test_regression.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2573,21 +2573,23 @@ def test__array_namespace__(self):
25732573
assert xp is np
25742574
xp = arr.__array_namespace__(api_version="2023.12")
25752575
assert xp is np
2576+
xp = arr.__array_namespace__(api_version="2024.12")
2577+
assert xp is np
25762578
xp = arr.__array_namespace__(api_version=None)
25772579
assert xp is np
25782580

25792581
with pytest.raises(
25802582
ValueError,
2581-
match="Version \"2024.12\" of the Array API Standard "
2583+
match="Version \"2025.12\" of the Array API Standard "
25822584
"is not supported."
25832585
):
2584-
arr.__array_namespace__(api_version="2024.12")
2586+
arr.__array_namespace__(api_version="2025.12")
25852587

25862588
with pytest.raises(
25872589
ValueError,
25882590
match="Only None and strings are allowed as the Array API version"
25892591
):
2590-
arr.__array_namespace__(api_version=2023)
2592+
arr.__array_namespace__(api_version=2024)
25912593

25922594
def test_isin_refcnt_bug(self):
25932595
# gh-25295

tools/ci/array-api-xfails.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,30 @@ array_api_tests/test_signatures.py::test_func_signature[vecdot]
2121

2222
# input is cast to min/max's dtype if they're different
2323
array_api_tests/test_operators_and_elementwise_functions.py::test_clip
24+
25+
# missing 'dtype' keyword argument
26+
array_api_tests/test_signatures.py::test_extension_func_signature[fft.fftfreq]
27+
array_api_tests/test_signatures.py::test_extension_func_signature[fft.rfftfreq]
28+
29+
# fails on np.repeat(np.array([]), np.array([])) test case
30+
array_api_tests/test_manipulation_functions.py::test_repeat
31+
32+
# NumPy matches Python behavior and it returns NaN and -1 in these cases
33+
array_api_tests/test_special_cases.py::test_binary[floor_divide(x1_i is +infinity and isfinite(x2_i) and x2_i > 0) -> +infinity]
34+
array_api_tests/test_special_cases.py::test_binary[floor_divide(x1_i is +infinity and isfinite(x2_i) and x2_i < 0) -> -infinity]
35+
array_api_tests/test_special_cases.py::test_binary[floor_divide(x1_i is -infinity and isfinite(x2_i) and x2_i > 0) -> -infinity]
36+
array_api_tests/test_special_cases.py::test_binary[floor_divide(x1_i is -infinity and isfinite(x2_i) and x2_i < 0) -> +infinity]
37+
array_api_tests/test_special_cases.py::test_binary[__floordiv__(x1_i is +infinity and isfinite(x2_i) and x2_i > 0) -> +infinity]
38+
array_api_tests/test_special_cases.py::test_binary[__floordiv__(x1_i is +infinity and isfinite(x2_i) and x2_i < 0) -> -infinity]
39+
array_api_tests/test_special_cases.py::test_binary[__floordiv__(x1_i is -infinity and isfinite(x2_i) and x2_i > 0) -> -infinity]
40+
array_api_tests/test_special_cases.py::test_binary[__floordiv__(x1_i is -infinity and isfinite(x2_i) and x2_i < 0) -> +infinity]
41+
array_api_tests/test_special_cases.py::test_binary[floor_divide(isfinite(x1_i) and x1_i > 0 and x2_i is -infinity) -> -0]
42+
array_api_tests/test_special_cases.py::test_binary[floor_divide(isfinite(x1_i) and x1_i < 0 and x2_i is +infinity) -> -0]
43+
array_api_tests/test_special_cases.py::test_binary[__floordiv__(isfinite(x1_i) and x1_i > 0 and x2_i is -infinity) -> -0]
44+
array_api_tests/test_special_cases.py::test_binary[__floordiv__(isfinite(x1_i) and x1_i < 0 and x2_i is +infinity) -> -0]
45+
array_api_tests/test_special_cases.py::test_iop[__ifloordiv__(x1_i is +infinity and isfinite(x2_i) and x2_i > 0) -> +infinity]
46+
array_api_tests/test_special_cases.py::test_iop[__ifloordiv__(x1_i is +infinity and isfinite(x2_i) and x2_i < 0) -> -infinity]
47+
array_api_tests/test_special_cases.py::test_iop[__ifloordiv__(x1_i is -infinity and isfinite(x2_i) and x2_i > 0) -> -infinity]
48+
array_api_tests/test_special_cases.py::test_iop[__ifloordiv__(x1_i is -infinity and isfinite(x2_i) and x2_i < 0) -> +infinity]
49+
array_api_tests/test_special_cases.py::test_iop[__ifloordiv__(isfinite(x1_i) and x1_i > 0 and x2_i is -infinity) -> -0]
50+
array_api_tests/test_special_cases.py::test_iop[__ifloordiv__(isfinite(x1_i) and x1_i < 0 and x2_i is +infinity) -> -0]

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy