ucon 0.5.2__py3-none-any.whl → 0.6.1__py3-none-any.whl
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.
- ucon/__init__.py +4 -1
- ucon/core.py +7 -2
- ucon/graph.py +8 -6
- ucon/maps.py +116 -0
- ucon/mcp/__init__.py +8 -0
- ucon/mcp/server.py +250 -0
- ucon/pydantic.py +199 -0
- ucon/units.py +261 -12
- {ucon-0.5.2.dist-info → ucon-0.6.1.dist-info}/METADATA +119 -98
- ucon-0.6.1.dist-info/RECORD +17 -0
- ucon-0.6.1.dist-info/entry_points.txt +2 -0
- ucon-0.6.1.dist-info/top_level.txt +1 -0
- tests/ucon/__init__.py +0 -3
- tests/ucon/conversion/__init__.py +0 -0
- tests/ucon/conversion/test_graph.py +0 -409
- tests/ucon/conversion/test_map.py +0 -409
- tests/ucon/test_algebra.py +0 -239
- tests/ucon/test_basis_transform.py +0 -521
- tests/ucon/test_core.py +0 -827
- tests/ucon/test_default_graph_conversions.py +0 -443
- tests/ucon/test_dimensionless_units.py +0 -248
- tests/ucon/test_graph_basis_transform.py +0 -263
- tests/ucon/test_quantity.py +0 -615
- tests/ucon/test_rebased_unit.py +0 -184
- tests/ucon/test_uncertainty.py +0 -264
- tests/ucon/test_unit_system.py +0 -174
- tests/ucon/test_units.py +0 -25
- tests/ucon/test_vector_fraction.py +0 -185
- ucon-0.5.2.dist-info/RECORD +0 -29
- ucon-0.5.2.dist-info/top_level.txt +0 -2
- {ucon-0.5.2.dist-info → ucon-0.6.1.dist-info}/WHEEL +0 -0
- {ucon-0.5.2.dist-info → ucon-0.6.1.dist-info}/licenses/LICENSE +0 -0
- {ucon-0.5.2.dist-info → ucon-0.6.1.dist-info}/licenses/NOTICE +0 -0
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
# © 2026 The Radiativity Company
|
|
2
|
-
# Licensed under the Apache License, Version 2.0
|
|
3
|
-
# See the LICENSE file for details.
|
|
4
|
-
|
|
5
|
-
"""
|
|
6
|
-
Tests for Vector with Fraction exponents.
|
|
7
|
-
|
|
8
|
-
Verifies backward compatibility with integer exponents and
|
|
9
|
-
correct behavior with fractional exponents for BasisTransform support.
|
|
10
|
-
"""
|
|
11
|
-
|
|
12
|
-
import unittest
|
|
13
|
-
from fractions import Fraction
|
|
14
|
-
|
|
15
|
-
from ucon.algebra import Vector
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
class TestVectorIntegerBackwardCompatibility(unittest.TestCase):
|
|
19
|
-
"""Verify existing integer-based code works unchanged."""
|
|
20
|
-
|
|
21
|
-
def test_integer_construction(self):
|
|
22
|
-
v = Vector(1, 0, -2, 0, 0, 0, 0, 0)
|
|
23
|
-
self.assertEqual(tuple(v), (1, 0, -2, 0, 0, 0, 0, 0))
|
|
24
|
-
|
|
25
|
-
def test_integer_addition(self):
|
|
26
|
-
v1 = Vector(1, 0, 0, 0, 0, 0, 0, 0)
|
|
27
|
-
v2 = Vector(0, 2, 0, 0, 0, 0, 0, 0)
|
|
28
|
-
result = v1 + v2
|
|
29
|
-
self.assertEqual(result, Vector(1, 2, 0, 0, 0, 0, 0, 0))
|
|
30
|
-
|
|
31
|
-
def test_integer_subtraction(self):
|
|
32
|
-
v1 = Vector(2, 1, 0, 0, 0, 0, 0, 0)
|
|
33
|
-
v2 = Vector(1, 1, 0, 0, 0, 0, 0, 0)
|
|
34
|
-
result = v1 - v2
|
|
35
|
-
self.assertEqual(result, Vector(1, 0, 0, 0, 0, 0, 0, 0))
|
|
36
|
-
|
|
37
|
-
def test_integer_scalar_multiplication(self):
|
|
38
|
-
v = Vector(1, -2, 0, 0, 0, 0, 3, 0)
|
|
39
|
-
result = v * 2
|
|
40
|
-
self.assertEqual(result, Vector(2, -4, 0, 0, 0, 0, 6, 0))
|
|
41
|
-
|
|
42
|
-
def test_integer_equality(self):
|
|
43
|
-
v1 = Vector(1, 0, 0, 0, 0, 0, 0, 0)
|
|
44
|
-
v2 = Vector(1, 0, 0, 0, 0, 0, 0, 0)
|
|
45
|
-
self.assertEqual(v1, v2)
|
|
46
|
-
|
|
47
|
-
def test_integer_hash_consistency(self):
|
|
48
|
-
v1 = Vector(1, 0, 0, 0, 0, 0, 0, 0)
|
|
49
|
-
v2 = Vector(1, 0, 0, 0, 0, 0, 0, 0)
|
|
50
|
-
self.assertEqual(hash(v1), hash(v2))
|
|
51
|
-
self.assertEqual(len({v1, v2}), 1)
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
class TestVectorFractionConstruction(unittest.TestCase):
|
|
55
|
-
"""Test Vector construction with Fraction values."""
|
|
56
|
-
|
|
57
|
-
def test_fraction_construction(self):
|
|
58
|
-
v = Vector(Fraction(3, 2), Fraction(1, 2), Fraction(-1), 0, 0, 0, 0, 0)
|
|
59
|
-
self.assertEqual(v.T, Fraction(3, 2))
|
|
60
|
-
self.assertEqual(v.L, Fraction(1, 2))
|
|
61
|
-
self.assertEqual(v.M, Fraction(-1))
|
|
62
|
-
|
|
63
|
-
def test_mixed_int_fraction_construction(self):
|
|
64
|
-
v = Vector(1, Fraction(1, 2), 0, 0, 0, 0, 0, 0)
|
|
65
|
-
self.assertEqual(v.T, Fraction(1))
|
|
66
|
-
self.assertEqual(v.L, Fraction(1, 2))
|
|
67
|
-
|
|
68
|
-
def test_float_converted_to_fraction(self):
|
|
69
|
-
v = Vector(0.5, 0, 0, 0, 0, 0, 0, 0)
|
|
70
|
-
self.assertEqual(v.T, Fraction(1, 2))
|
|
71
|
-
|
|
72
|
-
def test_default_values_are_fraction_zero(self):
|
|
73
|
-
v = Vector()
|
|
74
|
-
self.assertEqual(v.T, Fraction(0))
|
|
75
|
-
self.assertEqual(v.L, Fraction(0))
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
class TestVectorFractionEquality(unittest.TestCase):
|
|
79
|
-
"""Test equality across int and Fraction representations."""
|
|
80
|
-
|
|
81
|
-
def test_int_equals_fraction(self):
|
|
82
|
-
v1 = Vector(1, 0, 0, 0, 0, 0, 0, 0)
|
|
83
|
-
v2 = Vector(Fraction(1), Fraction(0), Fraction(0), Fraction(0),
|
|
84
|
-
Fraction(0), Fraction(0), Fraction(0), Fraction(0))
|
|
85
|
-
self.assertEqual(v1, v2)
|
|
86
|
-
|
|
87
|
-
def test_int_fraction_hash_equality(self):
|
|
88
|
-
v1 = Vector(1, 0, -2, 0, 0, 0, 0, 0)
|
|
89
|
-
v2 = Vector(Fraction(1), Fraction(0), Fraction(-2), Fraction(0),
|
|
90
|
-
Fraction(0), Fraction(0), Fraction(0), Fraction(0))
|
|
91
|
-
self.assertEqual(hash(v1), hash(v2))
|
|
92
|
-
|
|
93
|
-
def test_int_fraction_in_set(self):
|
|
94
|
-
v1 = Vector(1, 0, 0, 0, 0, 0, 0, 0)
|
|
95
|
-
v2 = Vector(Fraction(1), 0, 0, 0, 0, 0, 0, 0)
|
|
96
|
-
s = {v1, v2}
|
|
97
|
-
self.assertEqual(len(s), 1)
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
class TestVectorFractionArithmetic(unittest.TestCase):
|
|
101
|
-
"""Test arithmetic with Fraction exponents."""
|
|
102
|
-
|
|
103
|
-
def test_fraction_addition(self):
|
|
104
|
-
v1 = Vector(Fraction(1, 2), 0, 0, 0, 0, 0, 0, 0)
|
|
105
|
-
v2 = Vector(Fraction(1, 2), 0, 0, 0, 0, 0, 0, 0)
|
|
106
|
-
result = v1 + v2
|
|
107
|
-
self.assertEqual(result.T, Fraction(1))
|
|
108
|
-
|
|
109
|
-
def test_fraction_subtraction(self):
|
|
110
|
-
v1 = Vector(Fraction(3, 2), 0, 0, 0, 0, 0, 0, 0)
|
|
111
|
-
v2 = Vector(Fraction(1, 2), 0, 0, 0, 0, 0, 0, 0)
|
|
112
|
-
result = v1 - v2
|
|
113
|
-
self.assertEqual(result.T, Fraction(1))
|
|
114
|
-
|
|
115
|
-
def test_fraction_scalar_multiply(self):
|
|
116
|
-
v = Vector(Fraction(1, 2), 0, 0, 0, 0, 0, 0, 0)
|
|
117
|
-
result = v * 2
|
|
118
|
-
self.assertEqual(result.T, Fraction(1))
|
|
119
|
-
|
|
120
|
-
def test_fraction_scalar_multiply_by_fraction(self):
|
|
121
|
-
v = Vector(1, 0, 0, 0, 0, 0, 0, 0)
|
|
122
|
-
result = v * Fraction(1, 2)
|
|
123
|
-
self.assertEqual(result.T, Fraction(1, 2))
|
|
124
|
-
|
|
125
|
-
def test_no_floating_point_drift(self):
|
|
126
|
-
# 1/3 * 3 should equal exactly 1, not 0.9999...
|
|
127
|
-
v = Vector(Fraction(1, 3), 0, 0, 0, 0, 0, 0, 0)
|
|
128
|
-
result = v * 3
|
|
129
|
-
self.assertEqual(result.T, Fraction(1))
|
|
130
|
-
self.assertEqual(result, Vector(1, 0, 0, 0, 0, 0, 0, 0))
|
|
131
|
-
|
|
132
|
-
def test_complex_fraction_arithmetic(self):
|
|
133
|
-
# CGS-ESU charge dimension: M^(1/2) · L^(3/2) · T^(-1)
|
|
134
|
-
esu_charge = Vector(
|
|
135
|
-
T=-1,
|
|
136
|
-
L=Fraction(3, 2),
|
|
137
|
-
M=Fraction(1, 2),
|
|
138
|
-
)
|
|
139
|
-
# Multiply by 2 (squaring the unit)
|
|
140
|
-
squared = esu_charge * 2
|
|
141
|
-
self.assertEqual(squared.T, Fraction(-2))
|
|
142
|
-
self.assertEqual(squared.L, Fraction(3))
|
|
143
|
-
self.assertEqual(squared.M, Fraction(1))
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
class TestVectorIterationWithFraction(unittest.TestCase):
|
|
147
|
-
"""Test iteration and length with Fraction values."""
|
|
148
|
-
|
|
149
|
-
def test_iteration_returns_fractions(self):
|
|
150
|
-
v = Vector(Fraction(1, 2), 1, 0, 0, 0, 0, 0, 0)
|
|
151
|
-
components = list(v)
|
|
152
|
-
self.assertEqual(components[0], Fraction(1, 2))
|
|
153
|
-
self.assertEqual(components[1], Fraction(1))
|
|
154
|
-
|
|
155
|
-
def test_length_unchanged(self):
|
|
156
|
-
v = Vector(Fraction(1, 2), 0, 0, 0, 0, 0, 0, 0)
|
|
157
|
-
self.assertEqual(len(v), 8)
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
class TestVectorNegation(unittest.TestCase):
|
|
161
|
-
"""Test vector negation with Fraction values."""
|
|
162
|
-
|
|
163
|
-
def test_negation_with_fractions(self):
|
|
164
|
-
v = Vector(Fraction(1, 2), Fraction(-3, 4), 0, 0, 0, 0, 0, 0)
|
|
165
|
-
neg = -v
|
|
166
|
-
self.assertEqual(neg.T, Fraction(-1, 2))
|
|
167
|
-
self.assertEqual(neg.L, Fraction(3, 4))
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
class TestVectorRightMultiply(unittest.TestCase):
|
|
171
|
-
"""Test right multiplication (scalar * vector)."""
|
|
172
|
-
|
|
173
|
-
def test_rmul_integer(self):
|
|
174
|
-
v = Vector(Fraction(1, 2), 0, 0, 0, 0, 0, 0, 0)
|
|
175
|
-
result = 2 * v
|
|
176
|
-
self.assertEqual(result.T, Fraction(1))
|
|
177
|
-
|
|
178
|
-
def test_rmul_fraction(self):
|
|
179
|
-
v = Vector(1, 0, 0, 0, 0, 0, 0, 0)
|
|
180
|
-
result = Fraction(1, 2) * v
|
|
181
|
-
self.assertEqual(result.T, Fraction(1, 2))
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
if __name__ == "__main__":
|
|
185
|
-
unittest.main()
|
ucon-0.5.2.dist-info/RECORD
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
tests/ucon/__init__.py,sha256=9BAHYTs27Ed3VgqiMUH4XtVttAmOPgK0Zvj-dUNo7D8,119
|
|
2
|
-
tests/ucon/test_algebra.py,sha256=NnoQOSMW8NJlOTnbr3M_5epvnDPXpVTgO21L2LcytRY,8503
|
|
3
|
-
tests/ucon/test_basis_transform.py,sha256=P7ccr9wgDPCwCmsj4dceu3V0A72qFbTavjzm9kB3xP8,16710
|
|
4
|
-
tests/ucon/test_core.py,sha256=bmwSRWPlhwossy5NJ9rcPWujFmzBBPOeZzPAzN1acFg,32631
|
|
5
|
-
tests/ucon/test_default_graph_conversions.py,sha256=rkcDcSV1_kZeuPf4ModHDpgfkOPZS32xcKq7KPDRN-0,15760
|
|
6
|
-
tests/ucon/test_dimensionless_units.py,sha256=K6BrIPOFL9IO_ksR8t_oJUXmjTgqBUzMdgaV-hZc52w,8410
|
|
7
|
-
tests/ucon/test_graph_basis_transform.py,sha256=5-WglJaR1N_mJlqR6i8NuxLJ_FASqb5a8WoO_177smU,8249
|
|
8
|
-
tests/ucon/test_quantity.py,sha256=md5nbmy0u2cFBdqNeu-ROhoj29vYrIlGm_AjlmCttgc,24519
|
|
9
|
-
tests/ucon/test_rebased_unit.py,sha256=n2mksEYSJ8UJJXXwlgaLKg3THaf7_LKzWB7kwjoaXEU,5150
|
|
10
|
-
tests/ucon/test_uncertainty.py,sha256=KkJw2dJR0EToxPpBN24x735jr9fv6a2myxjvhOH4MPU,9649
|
|
11
|
-
tests/ucon/test_unit_system.py,sha256=gRc3fMvo9ded1tBUQWLKpcbpBepMAb7gPu8XvFzQZaM,5860
|
|
12
|
-
tests/ucon/test_units.py,sha256=SILymDtDNDyxEhkYQubrfkakKCMexwEwjyHfhrkDrMI,869
|
|
13
|
-
tests/ucon/test_vector_fraction.py,sha256=fTgxlV9aSP15sA4gATTXBzIDbtKXwWqG1Ip0o-V2B4Y,6369
|
|
14
|
-
tests/ucon/conversion/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
|
-
tests/ucon/conversion/test_graph.py,sha256=fs0aP6qNf8eE1uI7SoGSCW2XAkHYb7T9aaI-kzmO02c,16955
|
|
16
|
-
tests/ucon/conversion/test_map.py,sha256=DVFQ3xwp16Nuy9EtZRjKlWbkXfRUcM1mOzFrS4HhOaw,13886
|
|
17
|
-
ucon/__init__.py,sha256=M_sijIUYPvU87Jtnq_O2X7TS4x9RW1LHZJ8bbm3gfk0,2255
|
|
18
|
-
ucon/algebra.py,sha256=6QrPyD23L93XSrnIORcYEx2CLDv4WDcrh6H_hxeeOus,8668
|
|
19
|
-
ucon/core.py,sha256=j2Xw73-Xuh0CkaUYEv5ljsxjt-XdthiH-EbqUBgG1a8,63139
|
|
20
|
-
ucon/graph.py,sha256=Ec0Q2QiAGUm2RaxrKnpFHtwpNvTf4PYbvo62BWtGJG8,21159
|
|
21
|
-
ucon/maps.py,sha256=tWP4ayYCEazJzf81EP1_fmtADhg18D1eHldudAMEY0U,5460
|
|
22
|
-
ucon/quantity.py,sha256=GBxZ_96nocx-8F-usNWGbPvWHRhRgdZzqfH9Sx69iC4,465
|
|
23
|
-
ucon/units.py,sha256=MWCJhicK6jQb71fREyW_HSfGFKL8KEQej2JnySL_MjE,8285
|
|
24
|
-
ucon-0.5.2.dist-info/licenses/LICENSE,sha256=LtimSYBSw1L_X6n1-VEdZRdwuROzPumrMUNX21asFuI,11356
|
|
25
|
-
ucon-0.5.2.dist-info/licenses/NOTICE,sha256=bh4fBOItio3kM4hSNYhqfFpcaAvOoixjD7Du8im-sYA,1079
|
|
26
|
-
ucon-0.5.2.dist-info/METADATA,sha256=CTRgYp67awjnjy7ZzKL2opd81T2RK1feQ6AXMnXmSj4,17200
|
|
27
|
-
ucon-0.5.2.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
28
|
-
ucon-0.5.2.dist-info/top_level.txt,sha256=zZYRJiQrVUtN32ziJD2YEq7ClSvDmVYHYy5ArRAZGxI,11
|
|
29
|
-
ucon-0.5.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|