Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

extra.array_api versioning + complex support #3456

Merged
merged 62 commits into from
Sep 29, 2022
Merged
Show file tree
Hide file tree
Changes from 60 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
b51512f
Rudimentary xps versioning and complex support
honno Sep 6, 2022
e08ce5a
Fix argument validation for complex dtypes
honno Sep 12, 2022
8b6acaf
Fix `check_set_value()` for complex numbers with inf components
honno Sep 12, 2022
19d88a4
Use check functions for `api_version` validation
honno Sep 12, 2022
94e0257
Fix and test `api_version` inferrence
honno Sep 13, 2022
023d901
Parametrize `xp` with most recent supporting `api_version` in tests
honno Sep 13, 2022
a7a2ed0
Raise helpful error when inferring `api_version` when no `zeros()`
honno Sep 14, 2022
18d1c70
More explicit `api_version` arg validation
honno Sep 14, 2022
1684a15
Remove unnecessary `tuple()`
honno Sep 14, 2022
a170115
Fix `test_warns_on_specifying_unsupported_version`
honno Sep 14, 2022
90662cf
Delete redundant test file
honno Sep 14, 2022
387aa60
Remove erroneous and otherwise unused `complex128` var
honno Sep 15, 2022
858939d
Skip Array API tests requiring greater `api_version`
honno Sep 16, 2022
4784e05
Change `test_can_generate_{scalar/numeric}_dtypes` on runtime
honno Sep 16, 2022
309a049
Fix `test_strategeis_namespace_repr`
honno Sep 16, 2022
0d34426
Pass `api_version` to `find_castable_builtin_for_dtype()`
honno Sep 16, 2022
c9018d0
Spelling fix for `api_vers{i}on_gt()`
honno Sep 16, 2022
2189374
Change `test_draw_arrays_from_dtype_name_strategies` on runtime
honno Sep 16, 2022
4106eb8
Fix not-actually-literally `Literal` uses
honno Sep 16, 2022
cf2d96a
Remove use of value-bound kwargs for `xps.from_dtype()` on complex
honno Sep 16, 2022
b35de45
Improve error message for invalid `api_version`
honno Sep 16, 2022
dcb426e
Parametrize `xp` for `test_make_namespace_raises_invalid_argument`
honno Sep 16, 2022
bf020f4
Cache `make_strategies_namespace()` with a `WeakValueDictionary()`
honno Sep 19, 2022
5cad500
`test/array_api/conftest.py` changes
honno Sep 19, 2022
7af2d8d
Env for specifying `api_version` in `tests/array_api/
honno Sep 19, 2022
df88bf4
Hold meta attributes in strategies namespace and validate for them
honno Sep 19, 2022
cbd157f
`xps.complex_dtypes` raises when `api_version="2021.12"`
honno Sep 19, 2022
47a823f
Descriptive comment and error for complex branch in `xps.from_dtype()`
honno Sep 19, 2022
a19b8dc
Prettier `mock_xps` definition
honno Sep 19, 2022
2f8042e
Minor doc fixes
honno Sep 20, 2022
bcfe278
Use kw-only args for `array_api.ArrayStrategy`
honno Sep 20, 2022
3156ccb
Use `contextlib.suppress()` for `api_version` inferrence
honno Sep 20, 2022
b3ce0e2
`None` replaces `...` for `api_version`
honno Sep 20, 2022
4bd1dfa
Note on future `api_version` test parametrization in readme
honno Sep 20, 2022
68593b5
`MIN_VER_FOR_COMPLEX` constant for test suite
honno Sep 20, 2022
751edc3
`find_any()` testing and refactoring for `test_scalar_dtypes.py`
honno Sep 20, 2022
5a67c58
Test case for sizes-as-int in `xps.complex_dtypes()`
honno Sep 20, 2022
7224514
docs: update `xps` hack in docs, list `xps.real_dtypes()`
honno Sep 20, 2022
ecb8057
Update `make_strategies_namespace()` docstring
honno Sep 20, 2022
cdfdbd6
`tests/array_api/` docstrings and re-org
honno Sep 20, 2022
b87ad8d
Mark params with complex in `test_strategy_can_generate_every_dtype`
honno Sep 20, 2022
0f88cdf
Use `__array_api_version__` for version inferrence
honno Sep 22, 2022
edd8f87
Handle modules lacking `__array_api_version__` in `tests/array_api/`
honno Sep 22, 2022
53fcd6f
Just use the mock for `tests/array_api/` by default
honno Sep 22, 2022
97e516f
`conftest.py`: Fix entrypoint logic, use `else` in a `try-except`
honno Sep 22, 2022
87b643b
Note decisions in complex branch of `array_api._from_dtype()`
honno Sep 23, 2022
1c22c6c
Add `RELEASE.rst`
honno Sep 23, 2022
17b1a76
Clarify "real-valued" for `xps.floating_dtypes()` docstring
honno Sep 23, 2022
bcf2117
Lint fix for raised error inside an except
honno Sep 23, 2022
56a59b4
Fix doc warning on commenting inside directive
honno Sep 23, 2022
1ee6b45
mypy fixes and ignores
honno Sep 23, 2022
8d4386d
Remove a misleading and an unnecessary comment
honno Sep 26, 2022
e7cee0c
Explain the why in `RELEASE.rst`
honno Sep 27, 2022
556aba4
Remove redundant `api_version_gt()` util
honno Sep 27, 2022
89ee94b
Move ini registration of `xp_min_version()` to top-level conftest
honno Sep 27, 2022
d0c353c
Clearer `xp_min_version()` logic in modifyitems hook
honno Sep 27, 2022
a5dd305
Revert erroneous docstring change
honno Sep 27, 2022
927b80a
Include `xp` name in `complex_dtypes()` error
honno Sep 27, 2022
2a884fa
Sanity check for `MIN_VER_FOR_COMPLEX`
honno Sep 27, 2022
057d4de
`make_strategies_namespace()` repr omits `api_version` when inferred
honno Sep 27, 2022
bc4bcb6
Distinct cache keys when `api_version=None`
honno Sep 28, 2022
0e5155d
Inferred `api_version` shares cache key with specified versions
honno Sep 29, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions hypothesis-python/RELEASE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
RELEASE_TYPE: minor

In preparation for `future versions of the Array API standard
<https://data-apis.org/array-api/latest/future_API_evolution.html>`__,
:func:`~hypothesis.extra.array_api.make_strategies_namespace` now accepts an
optional ``api_version`` argument, which determines the version conformed to by
the returned strategies namespace. If ``None``, the version of the passed array
module ``xp`` is inferred.

This release also introduces :func:`xps.real_dtypes`. This is currently
equivalent to the existing :func:`xps.numeric_dtypes` strategy, but exists
because the latter is expected to include complex numbers in the next version of
the standard.
10 changes: 8 additions & 2 deletions hypothesis-python/docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,16 @@ def setup(app):
app.tags.add("has_release_file")

# patch in mock array_api namespace so we can autodoc it
from hypothesis.extra.array_api import make_strategies_namespace, mock_xp
from hypothesis.extra.array_api import (
RELEASED_VERSIONS,
make_strategies_namespace,
mock_xp,
)

mod = types.ModuleType("xps")
mod.__dict__.update(make_strategies_namespace(mock_xp).__dict__)
mod.__dict__.update(
make_strategies_namespace(mock_xp, api_version=RELEASED_VERSIONS[-1]).__dict__
)
assert "xps" not in sys.modules
sys.modules["xps"] = mod

Expand Down
4 changes: 4 additions & 0 deletions hypothesis-python/docs/numpy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ The resulting namespace contains all our familiar strategies like
:func:`~xps.arrays` and :func:`~xps.from_dtype`, but based on the Array API
standard semantics and returning objects from the ``xp`` module:

..
TODO: for next released xp version, include complex_dtypes here

.. automodule:: xps
:members:
from_dtype,
Expand All @@ -83,6 +86,7 @@ standard semantics and returning objects from the ``xp`` module:
scalar_dtypes,
boolean_dtypes,
numeric_dtypes,
real_dtypes,
integer_dtypes,
unsigned_integer_dtypes,
floating_dtypes,
Expand Down