ansys-units 0.4.dev0__tar.gz → 0.5.dev0__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.
- {ansys_units-0.4.dev0 → ansys_units-0.5.dev0}/PKG-INFO +8 -7
- {ansys_units-0.4.dev0 → ansys_units-0.5.dev0}/pyproject.toml +8 -7
- {ansys_units-0.4.dev0 → ansys_units-0.5.dev0}/src/ansys/units/quantity.py +41 -14
- {ansys_units-0.4.dev0 → ansys_units-0.5.dev0}/LICENSE +0 -0
- {ansys_units-0.4.dev0 → ansys_units-0.5.dev0}/README.rst +0 -0
- {ansys_units-0.4.dev0 → ansys_units-0.5.dev0}/src/ansys/units/__init__.py +0 -0
- {ansys_units-0.4.dev0 → ansys_units-0.5.dev0}/src/ansys/units/_constants.py +0 -0
- {ansys_units-0.4.dev0 → ansys_units-0.5.dev0}/src/ansys/units/_version.py +0 -0
- {ansys_units-0.4.dev0 → ansys_units-0.5.dev0}/src/ansys/units/base_dimensions.py +0 -0
- {ansys_units-0.4.dev0 → ansys_units-0.5.dev0}/src/ansys/units/cfg.yaml +0 -0
- {ansys_units-0.4.dev0 → ansys_units-0.5.dev0}/src/ansys/units/dimensions.py +0 -0
- {ansys_units-0.4.dev0 → ansys_units-0.5.dev0}/src/ansys/units/docs/.gitignore +0 -0
- {ansys_units-0.4.dev0 → ansys_units-0.5.dev0}/src/ansys/units/quantity_tables/bt_table.yaml +0 -0
- {ansys_units-0.4.dev0 → ansys_units-0.5.dev0}/src/ansys/units/quantity_tables/cgs_table.yaml +0 -0
- {ansys_units-0.4.dev0 → ansys_units-0.5.dev0}/src/ansys/units/quantity_tables/si_table.yaml +0 -0
- {ansys_units-0.4.dev0 → ansys_units-0.5.dev0}/src/ansys/units/systems.py +0 -0
- {ansys_units-0.4.dev0 → ansys_units-0.5.dev0}/src/ansys/units/unit.py +0 -0
- {ansys_units-0.4.dev0 → ansys_units-0.5.dev0}/src/ansys/units/unit_registry.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ansys-units
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.dev0
|
|
4
4
|
Summary: Pythonic interface for units, unit systems, and unit conversions.
|
|
5
5
|
Author-email: "ANSYS, Inc." <pyansys.core@ansys.com>
|
|
6
6
|
Maintainer-email: "ANSYS, Inc." <pyansys.core@ansys.com>
|
|
@@ -17,15 +17,16 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
17
17
|
License-File: LICENSE
|
|
18
18
|
Requires-Dist: importlib-metadata>=4.0
|
|
19
19
|
Requires-Dist: pyyaml>=6.0
|
|
20
|
-
Requires-Dist: ansys-sphinx-theme==1.2
|
|
21
|
-
Requires-Dist:
|
|
22
|
-
Requires-Dist:
|
|
20
|
+
Requires-Dist: ansys-sphinx-theme==1.3.2 ; extra == "doc"
|
|
21
|
+
Requires-Dist: pdf2image==1.17.0 ; extra == "doc"
|
|
22
|
+
Requires-Dist: quarto-cli==1.6.42 ; extra == "doc"
|
|
23
|
+
Requires-Dist: matplotlib==3.10.1 ; extra == "doc"
|
|
23
24
|
Requires-Dist: numpydoc==1.8.0 ; extra == "doc"
|
|
24
25
|
Requires-Dist: Sphinx==7.4.7 ; extra == "doc"
|
|
25
26
|
Requires-Dist: sphinx-copybutton==0.5.2 ; extra == "doc"
|
|
26
|
-
Requires-Dist: sphinx-gallery==0.
|
|
27
|
-
Requires-Dist: sphinx-toggleprompt==0.
|
|
28
|
-
Requires-Dist: numpy==2.2.
|
|
27
|
+
Requires-Dist: sphinx-gallery==0.19.0 ; extra == "doc"
|
|
28
|
+
Requires-Dist: sphinx-toggleprompt==0.6.0 ; extra == "doc"
|
|
29
|
+
Requires-Dist: numpy==2.2.3 ; extra == "lists"
|
|
29
30
|
Requires-Dist: pytest==8.3.4 ; extra == "tests"
|
|
30
31
|
Requires-Dist: pytest-cov==6.0.0 ; extra == "tests"
|
|
31
32
|
Requires-Dist: pytest-mock==3.14.0 ; extra == "tests"
|
|
@@ -5,7 +5,7 @@ build-backend = "flit_core.buildapi"
|
|
|
5
5
|
[project]
|
|
6
6
|
# Check https://flit.readthedocs.io/en/latest/pyproject_toml.html for all available sections
|
|
7
7
|
name = "ansys-units"
|
|
8
|
-
version = "0.
|
|
8
|
+
version = "0.5.dev0"
|
|
9
9
|
description = "Pythonic interface for units, unit systems, and unit conversions."
|
|
10
10
|
readme = "README.rst"
|
|
11
11
|
requires-python = ">=3.9,<4"
|
|
@@ -30,14 +30,15 @@ dependencies = [
|
|
|
30
30
|
|
|
31
31
|
[project.optional-dependencies]
|
|
32
32
|
doc = [
|
|
33
|
-
"ansys-sphinx-theme==1.2
|
|
34
|
-
"
|
|
35
|
-
"
|
|
33
|
+
"ansys-sphinx-theme==1.3.2",
|
|
34
|
+
"pdf2image==1.17.0",
|
|
35
|
+
"quarto-cli==1.6.42",
|
|
36
|
+
"matplotlib==3.10.1",
|
|
36
37
|
"numpydoc==1.8.0",
|
|
37
38
|
"Sphinx==7.4.7",
|
|
38
39
|
"sphinx-copybutton==0.5.2",
|
|
39
|
-
"sphinx-gallery==0.
|
|
40
|
-
"sphinx-toggleprompt==0.
|
|
40
|
+
"sphinx-gallery==0.19.0",
|
|
41
|
+
"sphinx-toggleprompt==0.6.0",
|
|
41
42
|
]
|
|
42
43
|
tests = [
|
|
43
44
|
"pytest==8.3.4",
|
|
@@ -46,7 +47,7 @@ tests = [
|
|
|
46
47
|
"pint==0.24.4",
|
|
47
48
|
]
|
|
48
49
|
lists = [
|
|
49
|
-
"numpy==2.2.
|
|
50
|
+
"numpy==2.2.3",
|
|
50
51
|
]
|
|
51
52
|
|
|
52
53
|
[project.urls]
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
|
|
24
24
|
from __future__ import annotations
|
|
25
25
|
|
|
26
|
+
from collections.abc import Iterable
|
|
26
27
|
import operator
|
|
27
28
|
from typing import Union
|
|
28
29
|
|
|
@@ -37,6 +38,15 @@ try:
|
|
|
37
38
|
except ImportError:
|
|
38
39
|
_array = None
|
|
39
40
|
|
|
41
|
+
try:
|
|
42
|
+
from matplotlib.units import AxisInfo, ConversionInterface, registry
|
|
43
|
+
|
|
44
|
+
_ci = ConversionInterface
|
|
45
|
+
_ai = AxisInfo
|
|
46
|
+
_registry = registry
|
|
47
|
+
except ModuleNotFoundError:
|
|
48
|
+
_ci, _ai, _registry = object, None, dict()
|
|
49
|
+
|
|
40
50
|
|
|
41
51
|
class Quantity:
|
|
42
52
|
"""
|
|
@@ -89,6 +99,9 @@ class Quantity:
|
|
|
89
99
|
):
|
|
90
100
|
raise ExcessiveParameters()
|
|
91
101
|
|
|
102
|
+
self._value = value
|
|
103
|
+
self.unit = units
|
|
104
|
+
|
|
92
105
|
if copy_from:
|
|
93
106
|
if value:
|
|
94
107
|
units = copy_from.units
|
|
@@ -310,22 +323,10 @@ class Quantity:
|
|
|
310
323
|
dims(dimensions={base_dims.SOLID_ANGLE: 1.0}),
|
|
311
324
|
]:
|
|
312
325
|
return get_si_value(self)
|
|
313
|
-
raise InvalidFloatUsage()
|
|
314
|
-
|
|
315
|
-
def __array__(self):
|
|
316
|
-
if _array:
|
|
317
|
-
if isinstance(self.value, (float)):
|
|
318
|
-
return _array.array([self.value])
|
|
319
|
-
return self.value
|
|
320
|
-
else:
|
|
321
|
-
raise NumPyRequired()
|
|
322
326
|
|
|
323
327
|
def __getitem__(self, idx):
|
|
324
|
-
if
|
|
325
|
-
value
|
|
326
|
-
return Quantity(value, self.units)
|
|
327
|
-
else:
|
|
328
|
-
raise NumPyRequired()
|
|
328
|
+
if isinstance(self.value, Iterable):
|
|
329
|
+
return Quantity(value=float(self.value[idx]), units=self.units)
|
|
329
330
|
|
|
330
331
|
def __str__(self):
|
|
331
332
|
return f'({self.value}, "{self._unit.name}")'
|
|
@@ -525,3 +526,29 @@ class RequiresUniqueDimensions(ValueError):
|
|
|
525
526
|
super().__init__(
|
|
526
527
|
f"For '{unit.name}' to be added '{other_unit.name}' must be removed."
|
|
527
528
|
)
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+
class QuantityConverter(_ci):
|
|
532
|
+
|
|
533
|
+
@staticmethod
|
|
534
|
+
def convert(value, unit, axis):
|
|
535
|
+
if isinstance(value, Quantity):
|
|
536
|
+
return value._value
|
|
537
|
+
else:
|
|
538
|
+
return [quantity._value for quantity in value]
|
|
539
|
+
|
|
540
|
+
@staticmethod
|
|
541
|
+
def axisinfo(unit, axis):
|
|
542
|
+
return _ai(label=unit)
|
|
543
|
+
|
|
544
|
+
@staticmethod
|
|
545
|
+
def default_units(x, axis):
|
|
546
|
+
"Return the default unit for x or None"
|
|
547
|
+
if isinstance(x, Quantity):
|
|
548
|
+
attr = getattr(x, "unit", None)
|
|
549
|
+
else:
|
|
550
|
+
attr = getattr(x[0], "unit", None)
|
|
551
|
+
return attr.name if isinstance(attr, Unit) else attr
|
|
552
|
+
|
|
553
|
+
|
|
554
|
+
_registry[Quantity] = QuantityConverter()
|
|
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
|
{ansys_units-0.4.dev0 → ansys_units-0.5.dev0}/src/ansys/units/quantity_tables/cgs_table.yaml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|