Skip to content

Commit 0011d23

Browse files
committed
Add flags functions to Sphinx documentation
1 parent 654865d commit 0011d23

File tree

5 files changed

+55
-12
lines changed

5 files changed

+55
-12
lines changed

array_api_strict/_flags.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,22 +91,20 @@ def set_array_api_strict_flags(
9191
array-api-strict. The default is ``{default_extensions}``. Note that
9292
some extensions require a minimum version of the standard.
9393
94-
The default values of the flags can also be changed by setting environment
95-
variables:
96-
97-
- ``ARRAY_API_STRICT_API_VERSION``: A string representing the version number.
98-
- ``ARRAY_API_STRICT_DATA_DEPENDENT_SHAPES``: "True" or "False".
99-
- ``ARRAY_API_STRICT_ENABLED_EXTENSIONS``: A comma separated list of
100-
extensions to enable.
94+
The flags can also be changed by setting :ref:`environment variables
95+
<environment-variables>`.
10196
10297
Examples
10398
--------
10499
105100
>>> from array_api_strict import set_array_api_strict_flags
101+
106102
>>> # Set the standard version to 2021.12
107103
>>> set_array_api_strict_flags(api_version="2021.12")
104+
108105
>>> # Disable data-dependent shapes
109106
>>> set_array_api_strict_flags(data_dependent_shapes=False)
107+
110108
>>> # Enable only the linalg extension (disable the fft extension)
111109
>>> set_array_api_strict_flags(enabled_extensions=["linalg"])
112110
@@ -192,13 +190,17 @@ def reset_array_api_strict_flags():
192190
"""
193191
Reset the array-api-strict flags to their default values.
194192
195-
This will also reset any flags that were set by environment variables.
193+
This will also reset any flags that were set by :ref:`environment
194+
variables <environment-variables>` back to their default values.
196195
197196
.. note::
198197
199198
This function is **not** part of the array API standard. It only exists
200199
in array-api-strict.
201200
201+
See :func:`set_array_api_strict_flags` for a list of flags and their
202+
default values.
203+
202204
Examples
203205
--------
204206
@@ -229,7 +231,7 @@ class ArrayAPIStrictFlags:
229231
This class is **not** part of the array API standard. It only exists
230232
in array-api-strict.
231233
232-
See :func:`~.array_api_strict.set_array_api_strict_flags` for a
234+
See :func:`set_array_api_strict_flags` for a
233235
description of the available flags.
234236
235237
See Also

docs/api.rst

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
API Reference
2+
=============
3+
4+
.. automodule:: array_api_strict
5+
6+
Array API Strict Flags
7+
----------------------
8+
9+
.. automodule:: array_api_strict._flags
10+
11+
.. currentmodule:: array_api_strict
12+
13+
.. autofunction:: get_array_api_strict_flags
14+
.. autofunction:: set_array_api_strict_flags
15+
.. autofunction:: reset_array_api_strict_flags
16+
.. autoclass:: ArrayAPIStrictFlags
17+
18+
.. _environment-variables:
19+
20+
Environment Variables
21+
~~~~~~~~~~~~~~~~~~~~~
22+
23+
Flags can also be set with environment variables.
24+
:func:`set_array_api_strict_flags` will override the values set by environment
25+
variables. Note that the environment variables will only change the defaults
26+
used by array-api-strict initially. They will not change the defaults used by
27+
:func:`reset_array_api_strict_flags`.
28+
29+
.. envvar:: ARRAY_API_STRICT_API_VERSION
30+
31+
A string representing the version number.
32+
33+
.. envvar:: ARRAY_API_STRICT_DATA_DEPENDENT_SHAPES
34+
35+
"True" or "False" to enable or disable data dependent shapes.
36+
37+
.. envvar:: ARRAY_API_STRICT_ENABLED_EXTENSIONS
38+
39+
A comma separated list of extensions to enable.

docs/changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
This is the first release of `array_api_strict`. It is extracted from
2121
`numpy.array_api`, which was included as an experimental submodule in NumPy
2222
versions prior to 2.0. Note that the commit history in this repository is
23-
extracted from the git history of numpy/array_api/ (see the [README](README.md)).
23+
extracted from the git history of numpy/array_api/ (see [](numpy.array_api)).
2424

2525
Additionally, the following changes are new to `array_api_strict` from
2626
`numpy.array_api` in NumPy 1.26 (the last NumPy feature release to include

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222

2323
extensions = [
2424
'myst_parser',
25-
# 'sphinx.ext.autodoc',
26-
# 'sphinx.ext.napoleon',
25+
'sphinx.ext.autodoc',
26+
'sphinx.ext.napoleon',
2727
# 'sphinx.ext.intersphinx',
2828
'sphinx_copybutton',
2929
]

docs/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ issue, but this hasn't necessarily been tested thoroughly.
183183
API standard. [Support for 2023.12 is
184184
planned](https://github.com/data-apis/array-api-strict/issues/25).
185185

186+
(numpy.array_api)=
186187
## Relationship to `numpy.array_api`
187188

188189
Previously this implementation was available as `numpy.array_api`, but it was
@@ -201,5 +202,6 @@ git_filter_repo.py --path numpy/array_api/ --path-rename numpy/array_api:array_a
201202
:titlesonly:
202203
:hidden:
203204
205+
api.rst
204206
changelog.md
205207
```

0 commit comments

Comments
 (0)