-
Notifications
You must be signed in to change notification settings - Fork 10
MAINT: various backports and tweaks #146
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -191,10 +191,6 @@ markers = [ | |
|
||
[tool.coverage] | ||
run.source = ["array_api_extra"] | ||
report.exclude_also = [ | ||
'\.\.\.', | ||
'if TYPE_CHECKING:', | ||
] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Caused large sections of code to be incorrectly skipped |
||
|
||
# mypy | ||
|
||
|
@@ -314,10 +310,5 @@ checks = [ | |
"ES01", # most docstrings do not need an extended summary | ||
] | ||
exclude = [ # don't report on objects that match any of these regex | ||
'.*test_at.*', | ||
'.*test_funcs.*', | ||
'.*test_testing.*', | ||
'.*test_utils.*', | ||
'.*test_version.*', | ||
'.*test_vendor.*', | ||
'.*test_*', | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,10 +7,10 @@ | |
from typing import cast | ||
|
||
from . import _compat | ||
from ._compat import is_array_api_obj, is_numpy_array | ||
from ._compat import array_namespace, is_array_api_obj, is_numpy_array | ||
from ._typing import Array | ||
|
||
__all__ = ["in1d", "mean"] | ||
__all__ = ["asarrays", "in1d", "is_python_scalar", "mean"] | ||
|
||
|
||
def in1d( | ||
|
@@ -33,7 +33,7 @@ def in1d( | |
https://github.com/numpy/numpy/blob/v1.26.0/numpy/lib/arraysetops.py#L524-L758 | ||
""" | ||
if xp is None: | ||
xp = _compat.array_namespace(x1, x2) | ||
xp = array_namespace(x1, x2) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: this causes coverage to fail, as this line isn't covered by unit tests |
||
|
||
# This code is run to make the code significantly faster | ||
if x2.shape[0] < 10 * x1.shape[0] ** 0.145: | ||
|
@@ -84,7 +84,7 @@ def mean( | |
Complex mean, https://github.com/data-apis/array-api/issues/846. | ||
""" | ||
if xp is None: | ||
xp = _compat.array_namespace(x) | ||
xp = array_namespace(x) | ||
|
||
if xp.isdtype(x.dtype, "complex floating"): | ||
x_real = xp.real(x) | ||
|
@@ -124,8 +124,8 @@ def asarrays( | |
---------- | ||
a, b : Array | int | float | complex | bool | ||
Input arrays or scalars. At least one must be an array. | ||
xp : ModuleType | ||
The standard-compatible namespace for the returned arrays. | ||
xp : array_namespace, optional | ||
The standard-compatible namespace for `x`. Default: infer. | ||
|
||
Returns | ||
------- | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
# To be changed to a Protocol later (see data-apis/array-api#589) | ||
Array = Any # type: ignore[no-any-explicit] | ||
Device = Any # type: ignore[no-any-explicit] | ||
DType = Any # type: ignore[no-any-explicit] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
Index = Any # type: ignore[no-any-explicit] | ||
|
||
__all__ = ["Array", "Device", "Index"] | ||
__all__ = ["Array", "DType", "Device", "Index"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,7 +115,11 @@ def xp( | |
if library == Backend.NUMPY_READONLY: | ||
return NumPyReadOnly() # type: ignore[return-value] # pyright: ignore[reportReturnType] | ||
xp = pytest.importorskip(library.value) | ||
# Possibly wrap module with array_api_compat | ||
xp = array_namespace(xp.empty(0)) | ||
|
||
# On Dask and JAX, monkey-patch all functions tagged by `lazy_xp_function` | ||
# in the global scope of the module containing the test function. | ||
patch_lazy_xp_functions(request, monkeypatch, xp=xp) | ||
|
||
if library == Backend.JAX: | ||
|
@@ -124,8 +128,18 @@ def xp( | |
# suppress unused-ignore to run mypy in -e lint as well as -e dev | ||
jax.config.update("jax_enable_x64", True) # type: ignore[no-untyped-call,unused-ignore] | ||
|
||
# Possibly wrap module with array_api_compat | ||
return array_namespace(xp.empty(0)) | ||
return xp | ||
|
||
|
||
@pytest.fixture(params=[Backend.DASK]) # Can select the test with `pytest -k dask` | ||
def da( | ||
request: pytest.FixtureRequest, monkeypatch: pytest.MonkeyPatch | ||
) -> ModuleType: # numpydoc ignore=PR01,RT01 | ||
"""Variant of the `xp` fixture that only yields dask.array.""" | ||
xp = pytest.importorskip("dask.array") | ||
xp = array_namespace(xp.empty(0)) | ||
patch_lazy_xp_functions(request, monkeypatch, xp=xp) | ||
return xp | ||
Comment on lines
+134
to
+142
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
|
||
@pytest.fixture | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ran pixi update. Notably this bumps dask to 2025.2.0.