Skip to content

Commit b9fc5c1

Browse files
committed
simplify xp-tests
1 parent 7e2e44f commit b9fc5c1

File tree

3 files changed

+23
-13
lines changed

3 files changed

+23
-13
lines changed

pixi.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,23 +55,21 @@ array-api-strict = "*"
5555
# clean array-api-tests dir
5656
clean-xp-tests = { cwd = ".", cmd = "rm -rf array-api-tests" }
5757
# clone array-api-tests
58-
clone-xp-tests.cmd = "git clone https://github.com/lucascolley/array-api-tests.git"
59-
clone-xp-tests.cwd = "."
60-
clone-xp-tests.depends-on = ["clean-xp-tests"]
61-
# checkout array-api-tests commit
62-
checkout-xp-tests.cmd = [
58+
clone-xp-tests.cmd = [
6359
"git",
64-
"reset",
65-
"--hard",
66-
"4244965fe1cdf1394143f089beac587307f375fa",
60+
"clone",
61+
"https://github.com/data-apis/array-api-tests.git",
62+
"&&",
63+
"cd",
64+
"array-api-tests",
6765
"&&",
6866
"git",
6967
"submodule",
7068
"update",
7169
"--init",
7270
]
73-
checkout-xp-tests.cwd = "array-api-tests"
74-
checkout-xp-tests.depends-on = ["clone-xp-tests"]
71+
clone-xp-tests.cwd = "."
72+
clone-xp-tests.depends-on = ["clean-xp-tests"]
7573
# run tests
7674
xp-tests.cmd = [
7775
"pytest",
@@ -92,9 +90,9 @@ xp-tests.cmd = [
9290
"--disable-deadline",
9391
"array_api_tests/",
9492
]
95-
xp-tests.env.ARRAY_API_TESTS_MODULE = "exec('import pint_array, array_api_strict; xp = pint_array.pint_namespace(array_api_strict)')"
93+
xp-tests.env.ARRAY_API_TESTS_MODULE = "pint_array.array_api_strict"
9694
xp-tests.cwd = "array-api-tests"
97-
xp-tests.depends-on = ["checkout-xp-tests"]
95+
xp-tests.depends-on = ["clone-xp-tests"]
9896

9997
[tool.pixi.feature.py310.dependencies]
10098
python = "~=3.10.0"

src/pint_array/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
from __future__ import annotations
99

10+
import importlib
11+
import sys
1012
import textwrap
1113
import types
1214
from typing import Generic
@@ -18,6 +20,16 @@
1820
__all__ = ["__version__", "pint_namespace"]
1921

2022

23+
def __getattr__(name):
24+
try:
25+
xp = importlib.import_module(name)
26+
mod = pint_namespace(xp)
27+
sys.modules[f"marray.{name}"] = mod
28+
return mod
29+
except ModuleNotFoundError as e:
30+
raise AttributeError(str(e)) from None
31+
32+
2133
def pint_namespace(xp):
2234
mod = types.ModuleType(f"pint({xp.__name__})")
2335

0 commit comments

Comments
 (0)