Skip to content

Commit c51249a

Browse files
committed
Update the api_version check to allow 2022.12 and warn on 2021.12
Not sure if a warning is the best option here. The returned namespace is 2022.12 compliant, and that is also 2021.12 compliant (except for a few minor things). I don't think it's worth trying to support both, unless someone has a real use-case.
1 parent 645f9a8 commit c51249a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

array_api_compat/common/_helpers.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import sys
1717
import math
1818
import inspect
19+
import warnings
1920

2021
def is_numpy_array(x):
2122
# Avoid importing NumPy if it isn't already
@@ -77,8 +78,10 @@ def is_array_api_obj(x):
7778
or hasattr(x, '__array_namespace__')
7879

7980
def _check_api_version(api_version):
80-
if api_version is not None and api_version != '2021.12':
81-
raise ValueError("Only the 2021.12 version of the array API specification is currently supported")
81+
if api_version == '2021.12':
82+
warnings.warn("The 2021.12 version of the array API specification was requested but the returned namespace is actually version 2022.12")
83+
if api_version is not None and api_version != '2022.12':
84+
raise ValueError("Only the 2022.12 version of the array API specification is currently supported")
8285

8386
def array_namespace(*xs, api_version=None, _use_compat=True):
8487
"""

0 commit comments

Comments
 (0)