unxts.api 2.0.0__tar.gz → 2.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {unxts_api-2.0.0 → unxts_api-2.0.1}/PKG-INFO +2 -2
- {unxts_api-2.0.0 → unxts_api-2.0.1}/src/unxts/api/_src/quantity.py +1 -1
- unxts_api-2.0.1/src/unxts/api/_src/units.py +33 -0
- {unxts_api-2.0.0 → unxts_api-2.0.1}/src/unxts/api/_version.py +2 -2
- {unxts_api-2.0.0 → unxts_api-2.0.1}/tests/test_public_api.py +10 -0
- unxts_api-2.0.0/src/unxts/api/_src/units.py +0 -20
- {unxts_api-2.0.0 → unxts_api-2.0.1}/.gitignore +0 -0
- {unxts_api-2.0.0 → unxts_api-2.0.1}/LICENSE +0 -0
- {unxts_api-2.0.0 → unxts_api-2.0.1}/README.md +0 -0
- {unxts_api-2.0.0 → unxts_api-2.0.1}/docs/api.md +0 -0
- {unxts_api-2.0.0 → unxts_api-2.0.1}/docs/extending.md +0 -0
- {unxts_api-2.0.0 → unxts_api-2.0.1}/docs/index.md +0 -0
- {unxts_api-2.0.0 → unxts_api-2.0.1}/pyproject.toml +0 -0
- {unxts_api-2.0.0 → unxts_api-2.0.1}/src/unxts/api/__init__.py +0 -0
- {unxts_api-2.0.0 → unxts_api-2.0.1}/src/unxts/api/_src/__init__.py +0 -0
- {unxts_api-2.0.0 → unxts_api-2.0.1}/src/unxts/api/_src/dimensions.py +0 -0
- {unxts_api-2.0.0 → unxts_api-2.0.1}/src/unxts/api/_src/unitsystems.py +0 -0
- {unxts_api-2.0.0 → unxts_api-2.0.1}/src/unxts/api/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: unxts.api
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.1
|
|
4
4
|
Summary: Abstract dispatch API definitions for unxt (canonical: unxts.api)
|
|
5
5
|
Project-URL: Bug Tracker, https://github.com/GalacticDynamics/unxt/issues
|
|
6
6
|
Project-URL: Homepage, https://github.com/GalacticDynamics/unxt
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"""Units API for unxt.
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Galactic Dynamics. All rights reserved.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
__all__ = ("unit", "unit_of")
|
|
7
|
+
|
|
8
|
+
from typing import TYPE_CHECKING, Any
|
|
9
|
+
|
|
10
|
+
import plum
|
|
11
|
+
|
|
12
|
+
if TYPE_CHECKING:
|
|
13
|
+
# `unit` is liberal in what it accepts (Postel's law): a unit object, a
|
|
14
|
+
# string, ... -> a unit. Declared here as a plain callable so static
|
|
15
|
+
# checkers can read the `Any` parameter -- in particular so it works as an
|
|
16
|
+
# `equinox.field(converter=unit)`, making `Quantity(1, "m")` type-check.
|
|
17
|
+
# (`plum.dispatch.abstract` erases the signature to an opaque `Function`
|
|
18
|
+
# that the converter field-specifier cannot introspect.) The `raise` body
|
|
19
|
+
# keeps pylint from inferring a `None` return for callers (this branch is
|
|
20
|
+
# type-checking only; the runtime definition is dispatched by plum).
|
|
21
|
+
def unit(obj: Any, /) -> Any:
|
|
22
|
+
raise NotImplementedError
|
|
23
|
+
|
|
24
|
+
else:
|
|
25
|
+
|
|
26
|
+
@plum.dispatch.abstract
|
|
27
|
+
def unit(obj: Any, /) -> Any:
|
|
28
|
+
"""Construct the units from a units object."""
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@plum.dispatch.abstract
|
|
32
|
+
def unit_of(obj: Any, /) -> Any:
|
|
33
|
+
"""Return the units of an object."""
|
|
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
|
|
|
18
18
|
commit_id: str | None
|
|
19
19
|
__commit_id__: str | None
|
|
20
20
|
|
|
21
|
-
__version__ = version = '2.0.
|
|
22
|
-
__version_tuple__ = version_tuple = (2, 0,
|
|
21
|
+
__version__ = version = '2.0.1'
|
|
22
|
+
__version_tuple__ = version_tuple = (2, 0, 1)
|
|
23
23
|
|
|
24
24
|
__commit_id__ = commit_id = None
|
|
@@ -17,3 +17,13 @@ def test_dispatch_functions_are_callable():
|
|
|
17
17
|
|
|
18
18
|
def test_version_is_a_string():
|
|
19
19
|
assert isinstance(unxts.api.__version__, str)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def test_wrap_to_keyword_form_redirects_to_positional():
|
|
23
|
+
"""``wrap_to(x, min=..., max=...)`` forwards to the positional method."""
|
|
24
|
+
|
|
25
|
+
@unxts.api.wrap_to.dispatch
|
|
26
|
+
def _(x: int, min: int, max: int, /) -> tuple:
|
|
27
|
+
return (x, min, max)
|
|
28
|
+
|
|
29
|
+
assert unxts.api.wrap_to(1, min=2, max=3) == (1, 2, 3)
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"""Units API for unxt.
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2023 Galactic Dynamics. All rights reserved.
|
|
4
|
-
"""
|
|
5
|
-
|
|
6
|
-
__all__ = ("unit", "unit_of")
|
|
7
|
-
|
|
8
|
-
from typing import Any
|
|
9
|
-
|
|
10
|
-
import plum
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
@plum.dispatch.abstract
|
|
14
|
-
def unit(obj: Any, /) -> Any:
|
|
15
|
-
"""Construct the units from a units object."""
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
@plum.dispatch.abstract
|
|
19
|
-
def unit_of(obj: Any, /) -> Any:
|
|
20
|
-
"""Return the units of an object."""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|