Skip to content

Commit 3f22545

Browse files
Revert "Revert "Split units file into with and without dimensions files"" (#49)
Reverts #45
2 parents 69e83fa + 212fb6d commit 3f22545

6 files changed

Lines changed: 3685 additions & 1213 deletions

File tree

test/test_dimension.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import tunits
2323
import tunits.core as core
24+
import tunits.units_with_dimension
2425

2526

2627
def _all_dimensions() -> Iterator[type[core.ValueWithDimension]]:
@@ -82,10 +83,10 @@ def test_arithmetic_ops_preserve_type_array(
8283

8384

8485
def test_division_type() -> None:
85-
t: tunits.Time = 3 * tunits.ns
86+
t: tunits.Time = 3 * tunits.units_with_dimension.ns
8687

8788
t = t / 2
88-
assert t == 1.5 * tunits.ns
89+
assert t == 1.5 * tunits.units_with_dimension.ns
8990

9091
assert isinstance(1 / t, tunits.Value)
9192

test/test_value_array.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,13 @@ def test_dimensionless_act_like_arrays() -> None:
9393
def test_repr() -> None:
9494
from tunits.units import km, kg, s
9595

96-
assert repr(s * []) == "TimeArray(array([], dtype=float64), 's')"
97-
assert repr(km * [2, 3]) == "LengthArray(array([2., 3.]), 'km')"
96+
assert repr(s * []) == "ValueArray(array([], dtype=float64), 's')"
97+
assert repr(km * [2, 3]) == "ValueArray(array([2., 3.]), 'km')"
9898
assert repr(km * kg * [3j]) == "ValueArray(array([0.+3.j]), 'kg*km')"
9999
assert repr(km**2 * [-1] / kg**3 * s) == "ValueArray(array([-1.]), 'km^2*s/kg^3')"
100100
assert repr(km ** (2 / 3.0) * [-1] / kg**3 * s) == "ValueArray(array([-1.]), 'km^(2/3)*s/kg^3')"
101101

102-
expected_repr = f"LengthArray({repr(np.array(range(50000), dtype=float))}, 'km')"
102+
expected_repr = f"ValueArray({repr(np.array(range(50000), dtype=float))}, 'km')"
103103
assert repr(list(range(50000)) * km) == expected_repr
104104

105105
# Fallback case.

test_perf/perf_testing_util.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@
2222

2323
import tunits
2424
from tunits import ValueWithDimension, ArrayWithDimension
25-
from tunits import units
25+
from tunits import units, units_with_dimension
2626
import tunits.core as core
2727

2828
_ALL_VALUES_WITH_DIMENSION = [
29-
obj for name in dir(units) if isinstance(obj := getattr(units, name), ValueWithDimension)
29+
obj
30+
for name in dir(units_with_dimension)
31+
if isinstance(obj := getattr(units_with_dimension, name), ValueWithDimension)
3032
]
3133

3234

tunits/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,4 @@
9696
)
9797

9898
from tunits.units import *
99+
import tunits.units_with_dimension

0 commit comments

Comments
 (0)