Skip to content

Commit eced421

Browse files
authored
Merge pull request #45 from asmeurer/release
array-api-strict 2.0 release
2 parents c54d5e0 + eb8dd46 commit eced421

File tree

4 files changed

+85
-54
lines changed

4 files changed

+85
-54
lines changed

array_api_strict/_flags.py

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -59,54 +59,59 @@ def set_array_api_strict_flags(
5959
Flags are global variables that enable or disable array-api-strict
6060
behaviors.
6161
62+
The flags can also be changed by setting :ref:`environment variables <environment-variables>`.
63+
6264
.. note::
6365
6466
This function is **not** part of the array API standard. It only exists
6567
in array-api-strict.
6668
67-
- `api_version`: The version of the standard to use. Supported
68-
versions are: ``{supported_versions}``. The default version number is
69-
``{default_version!r}``.
70-
71-
Note that 2021.12 is supported, but currently gives the same thing as
72-
2022.12 (except that the fft extension will be disabled).
69+
Parameters
70+
----------
71+
api_version : str, optional
72+
The version of the standard to use. Supported versions are:
73+
``{supported_versions}``. The default version number is
74+
``{default_version!r}``.
7375
74-
2023.12 support is experimental. Some features in 2023.12 may still be
75-
missing, and it hasn't been fully tested.
76+
Note that 2021.12 is supported, but currently gives the same thing as
77+
2022.12 (except that the fft extension will be disabled).
7678
77-
- `boolean_indexing`: Whether indexing by a boolean array is supported.
78-
Note that although boolean array indexing does result in data-dependent
79-
shapes, this flag is independent of the `data_dependent_shapes` flag
80-
(see below).
79+
2023.12 support is experimental. Some features in 2023.12 may still be
80+
missing, and it hasn't been fully tested. A future version of
81+
array-api-strict will change the default version to 2023.12.
8182
82-
- `data_dependent_shapes`: Whether data-dependent shapes are enabled in
83-
array-api-strict.
83+
boolean_indexing : bool, optional
84+
Whether indexing by a boolean array is supported.
85+
Note that although boolean array indexing does result in
86+
data-dependent shapes, this flag is independent of the
87+
`data_dependent_shapes` flag (see below).
8488
85-
This flag is enabled by default. Array libraries that use computation
86-
graphs may not be able to support functions whose output shapes depend
87-
on the input data.
89+
data_dependent_shapes : bool, optional
90+
Whether data-dependent shapes are enabled in array-api-strict.
91+
This flag is enabled by default. Array libraries that use computation
92+
graphs may not be able to support functions whose output shapes depend
93+
on the input data.
8894
89-
The functions that make use of data-dependent shapes, and are therefore
90-
disabled by setting this flag to False are
95+
The functions that make use of data-dependent shapes, and are therefore
96+
disabled by setting this flag to False are
9197
92-
- `unique_all()`, `unique_counts()`, `unique_inverse()`, and `unique_values()`.
93-
- `nonzero()`
94-
- `repeat()` when the `repeats` argument is an array (requires 2023.12
95-
version of the standard)
98+
- `unique_all()`, `unique_counts()`, `unique_inverse()`, and `unique_values()`.
99+
- `nonzero()`
100+
- `repeat()` when the `repeats` argument is an array (requires the
101+
2023.12 version of the standard)
96102
97-
Note that while boolean indexing is also data-dependent, it is
98-
controlled by a separate `boolean_indexing` flag (see above).
103+
Note that while boolean indexing is also data-dependent, it is
104+
controlled by a separate `boolean_indexing` flag (see above).
99105
100-
See
101-
https://data-apis.org/array-api/latest/design_topics/data_dependent_output_shapes.html
102-
for more details.
106+
See
107+
https://data-apis.org/array-api/latest/design_topics/data_dependent_output_shapes.html
108+
for more details.
103109
104-
- `enabled_extensions`: A list of extensions that are enabled in
105-
array-api-strict. The default is ``{default_extensions}``. Note that
106-
some extensions require a minimum version of the standard.
110+
enabled_extensions : list of str, optional
111+
A list of extensions that are enabled in array-api-strict. The default
112+
is ``{default_extensions}``. Note that some extensions require a
113+
minimum version of the standard.
107114
108-
The flags can also be changed by setting :ref:`environment variables
109-
<environment-variables>`.
110115
111116
Examples
112117
--------

docs/api.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ API Reference
33

44
.. automodule:: array_api_strict
55

6+
.. _array-api-strict-flags:
7+
68
Array API Strict Flags
79
----------------------
810

@@ -12,7 +14,6 @@ Array API Strict Flags
1214

1315
.. autofunction:: get_array_api_strict_flags
1416

15-
.. _set_array_api_strict_flags:
1617
.. autofunction:: set_array_api_strict_flags
1718
.. autofunction:: reset_array_api_strict_flags
1819
.. autoclass:: ArrayAPIStrictFlags

docs/changelog.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,34 @@
11
# Changelog
22

3+
## 2.0 (2024-06-27)
4+
5+
### Major Changes
6+
7+
- array-api-strict has a new set of [flags](array-api-strict-flags) that can
8+
be used to dynamically enable or disable features in array-api-strict. These
9+
flags allow you to change the supported array API version, enable or disable
10+
[extensions](https://data-apis.org/array-api/latest/extensions/index.html),
11+
enable or disable features that rely on data-dependent shapes, and enable or
12+
disable boolean indexing. Future versions may add additional flags to allow
13+
changing other optional or varying behaviors in the standard.
14+
15+
- Added experimental support for the
16+
[2023.12](https://data-apis.org/array-api/2023.12/changelog.html#v2023-12)
17+
version of the array API standard. The default version is still 2022.12, but
18+
the version can be changed to 2023.12 using the aforementioned flags, either
19+
by calling
20+
{func}`array_api_strict.set_array_api_strict_flags(api_version='2023.12')
21+
<array_api_strict.set_array_api_strict_flags>` or setting the environment
22+
variable {envvar}`ARRAY_API_STRICT_API_VERSION=2023.12
23+
<ARRAY_API_STRICT_API_VERSION>`. A future version of array-api-strict will
24+
change the default version to 2023.12.
25+
26+
### Minor Changes
27+
28+
- Calling `iter()` on an array now correctly raises `TypeError`.
29+
30+
- Add some missing names to `__all__`.
31+
332
## 1.1.1 (2024-04-29)
433

534
- Fix the `api_version` argument to `__array_namespace__` to accept

docs/index.md

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ array-api-strict currently supports the
2020
version of the standard. Experimental
2121
[2023.12](https://data-apis.org/array-api/latest/changelog.html#v2023-12)
2222
support is implemented, [but must be enabled with a
23-
flag](set_array_api_strict_flags).
23+
flag](array-api-strict-flags).
2424

2525
## Install
2626

@@ -37,7 +37,7 @@ and [Conda-forge](https://anaconda.org/conda-forge/array-api-strict)
3737
conda install --channel conda-forge array-api-strict
3838
```
3939

40-
array-api-strict supports NumPy 1.26 and (the upcoming) NumPy 2.0.
40+
array-api-strict supports NumPy 1.26 and NumPy 2.0.
4141

4242
## Rationale
4343

@@ -109,7 +109,7 @@ strict/minimal:
109109
like `sin` will accept integer array inputs, but the [standard only requires
110110
them to accept floating-point
111111
inputs](https://data-apis.org/array-api/latest/API_specification/generated/array_api.sin.html#array_api.sin),
112-
so in array-api-strict, `sin(integer_array)` will raise an exception.
112+
so in array-api-strict, `sin(asarray(0))` will raise an exception.
113113

114114
- The
115115
[indexing](https://data-apis.org/array-api/latest/API_specification/indexing.html)
@@ -131,6 +131,12 @@ strict/minimal:
131131
functions](https://data-apis.org/array-api/latest/API_specification/creation_functions.html)
132132
such as `asarray`.
133133

134+
- Optional behavior such as [optional
135+
extensions](https://data-apis.org/array-api/latest/extensions/index.html),
136+
functions that use data-dependent shapes, and boolean indexing are enabled
137+
by default but can disabled with the [array-api-strict
138+
flags](array-api-strict-flags).
139+
134140
## Caveats
135141

136142
array-api-strict is a thin pure Python wrapper around NumPy. NumPy 2.0 fully
@@ -170,23 +176,13 @@ issue, but this hasn't necessarily been tested thoroughly.
170176
this deviation may be tested with type checking. This [behavior may improve
171177
in the future](https://github.com/data-apis/array-api-strict/issues/6).
172178

173-
5. There are some behaviors in the standard that are not required to be
174-
implemented by libraries that cannot support [data dependent
175-
shapes](https://data-apis.org/array-api/latest/design_topics/data_dependent_output_shapes.html).
176-
This includes [the `unique_*`
177-
functions](https://data-apis.org/array-api/latest/API_specification/set_functions.html),
178-
[boolean array
179-
indexing](https://data-apis.org/array-api/latest/API_specification/indexing.html#boolean-array-indexing),
180-
and the
181-
[`nonzero`](https://data-apis.org/array-api/latest/API_specification/generated/array_api.nonzero.html)
182-
function. array-api-strict currently implements all of these. In the
183-
future, [there may be a way to disable them](https://github.com/data-apis/array-api-strict/issues/7).
184-
185-
6. array-api-strict currently uses the 2022.12 version of the array API
186-
standard. Support for 2023.12 is implemented but is still experimental and
187-
not fully tested. It can be enabled with
188-
[`array_api_strict.set_array_api_strict_flags(api_version='2023.12')`](set_array_api_strict_flags).
189-
179+
5. array-api-strict currently uses the 2022.12 version of the array API
180+
standard by default. Support for 2023.12 is implemented but is still
181+
experimental and not fully tested. It can be enabled with
182+
{func}`array_api_strict.set_array_api_strict_flags(api_version='2023.12')
183+
<array_api_strict.set_array_api_strict_flags>` or by setting the
184+
environment variable {envvar}`ARRAY_API_STRICT_API_VERSION=2023.12
185+
<ARRAY_API_STRICT_API_VERSION>`.
190186

191187
(numpy.array_api)=
192188
## Relationship to `numpy.array_api`

0 commit comments

Comments
 (0)