ucon 0.3.3rc2__tar.gz → 0.3.5__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.
Files changed (47) hide show
  1. ucon-0.3.5/LICENSE +202 -0
  2. ucon-0.3.5/NOTICE +28 -0
  3. {ucon-0.3.3rc2 → ucon-0.3.5}/PKG-INFO +49 -37
  4. {ucon-0.3.3rc2 → ucon-0.3.5}/README.md +45 -34
  5. {ucon-0.3.3rc2 → ucon-0.3.5}/ROADMAP.md +99 -91
  6. ucon-0.3.5/docs/decisions/composable-unit-algebra.md +241 -0
  7. ucon-0.3.5/docs/decisions/composite-units.md +160 -0
  8. ucon-0.3.5/docs/decisions/unit-algebra-naming.md +169 -0
  9. ucon-0.3.5/docs/explainers/type-operation-matrix.md +14 -0
  10. ucon-0.3.5/docs/explainers/why-algebraic-closure-matters.md +175 -0
  11. ucon-0.3.5/docs/explainers/why-type-safety-matters.md +92 -0
  12. ucon-0.3.5/docs/proposals/project_unified-algebraic-core.md +171 -0
  13. ucon-0.3.5/docs/proposals/unified-unit-presentation.md +168 -0
  14. {ucon-0.3.3rc2 → ucon-0.3.5}/noxfile.py +5 -1
  15. {ucon-0.3.3rc2 → ucon-0.3.5}/setup.py +6 -2
  16. ucon-0.3.5/tests/__init__.py +3 -0
  17. ucon-0.3.5/tests/ucon/__init__.py +3 -0
  18. ucon-0.3.5/tests/ucon/test_algebra.py +239 -0
  19. ucon-0.3.5/tests/ucon/test_core.py +828 -0
  20. ucon-0.3.5/tests/ucon/test_quantity.py +370 -0
  21. {ucon-0.3.3rc2 → ucon-0.3.5}/tests/ucon/test_units.py +7 -3
  22. {ucon-0.3.3rc2 → ucon-0.3.5}/ucon/__init__.py +9 -3
  23. ucon-0.3.5/ucon/algebra.py +216 -0
  24. ucon-0.3.5/ucon/core.py +818 -0
  25. ucon-0.3.5/ucon/quantity.py +196 -0
  26. {ucon-0.3.3rc2 → ucon-0.3.5}/ucon/units.py +5 -2
  27. {ucon-0.3.3rc2 → ucon-0.3.5}/ucon.egg-info/PKG-INFO +49 -37
  28. {ucon-0.3.3rc2 → ucon-0.3.5}/ucon.egg-info/SOURCES.txt +13 -4
  29. ucon-0.3.3rc2/LICENSE +0 -21
  30. ucon-0.3.3rc2/tests/__init__.py +0 -0
  31. ucon-0.3.3rc2/tests/ucon/__init__.py +0 -0
  32. ucon-0.3.3rc2/tests/ucon/test_core.py +0 -583
  33. ucon-0.3.3rc2/tests/ucon/test_dimension.py +0 -206
  34. ucon-0.3.3rc2/tests/ucon/test_unit.py +0 -143
  35. ucon-0.3.3rc2/ucon/core.py +0 -401
  36. ucon-0.3.3rc2/ucon/dimension.py +0 -172
  37. ucon-0.3.3rc2/ucon/unit.py +0 -92
  38. {ucon-0.3.3rc2 → ucon-0.3.5}/.github/workflows/publish.yaml +0 -0
  39. {ucon-0.3.3rc2 → ucon-0.3.5}/.github/workflows/tests.yaml +0 -0
  40. {ucon-0.3.3rc2 → ucon-0.3.5}/.gitignore +0 -0
  41. {ucon-0.3.3rc2 → ucon-0.3.5}/docs/decisions/unity-distance-metric-for-nearest-scale.md +0 -0
  42. {ucon-0.3.3rc2 → ucon-0.3.5}/docs/proposals/interface-unifying-the-value-layer.md +0 -0
  43. {ucon-0.3.3rc2 → ucon-0.3.5}/docs/proposals/support-for-fractional-exponents.md +0 -0
  44. {ucon-0.3.3rc2 → ucon-0.3.5}/requirements.txt +0 -0
  45. {ucon-0.3.3rc2 → ucon-0.3.5}/setup.cfg +0 -0
  46. {ucon-0.3.3rc2 → ucon-0.3.5}/ucon.egg-info/dependency_links.txt +0 -0
  47. {ucon-0.3.3rc2 → ucon-0.3.5}/ucon.egg-info/top_level.txt +0 -0
ucon-0.3.5/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright © 2025 The Radiativity Company
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
ucon-0.3.5/NOTICE ADDED
@@ -0,0 +1,28 @@
1
+ ucon — A dimensional analysis and unit algebra library
2
+ © 2025 The Radiativity Company
3
+
4
+ Licensed under the Apache License, Version 2.0.
5
+ You may not use this project except in compliance with the License.
6
+ A copy of the License is included in the LICENSE file or at:
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ This NOTICE file is part of the ucon distribution.
11
+
12
+ ucon implements:
13
+ • A compositional unit algebra (UnitFactor, UnitProduct, UnitForm)
14
+ • A dimension algebra based on vector-space operations
15
+ • Expression-level scale separation for unit provenance
16
+ • A foundation for ConversionGraph-based unit transformations
17
+
18
+ Portions of this software may incorporate or depend upon
19
+ third-party libraries. Attribution notices for those components,
20
+ if required, are included here or in the accompanying documentation.
21
+
22
+ The Radiativity Company retains all trademark rights to the names:
23
+ • "ucon"
24
+ • "The Radiativity Company"
25
+ • "Project Calico"
26
+
27
+ This file is for attribution purposes only and does not modify
28
+ the terms of the Apache License, Version 2.0.
@@ -1,18 +1,18 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ucon
3
- Version: 0.3.3rc2
3
+ Version: 0.3.5
4
4
  Summary: a tool for dimensional analysis: a "Unit CONverter"
5
5
  Home-page: https://github.com/withtwoemms/ucon
6
6
  Author: Emmanuel I. Obi
7
7
  Maintainer: Emmanuel I. Obi
8
8
  Maintainer-email: withtwoemms@gmail.com
9
- License: MIT
9
+ License: Apache-2.0
10
10
  Classifier: Development Status :: 3 - Alpha
11
11
  Classifier: Intended Audience :: Developers
12
12
  Classifier: Intended Audience :: Education
13
13
  Classifier: Intended Audience :: Science/Research
14
14
  Classifier: Topic :: Software Development :: Build Tools
15
- Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: License :: OSI Approved :: Apache Software License
16
16
  Classifier: Programming Language :: Python :: 3.7
17
17
  Classifier: Programming Language :: Python :: 3.8
18
18
  Classifier: Programming Language :: Python :: 3.9
@@ -23,6 +23,7 @@ Classifier: Programming Language :: Python :: 3.13
23
23
  Classifier: Programming Language :: Python :: 3.14
24
24
  Description-Content-Type: text/markdown
25
25
  License-File: LICENSE
26
+ License-File: NOTICE
26
27
  Dynamic: author
27
28
  Dynamic: classifier
28
29
  Dynamic: description
@@ -54,8 +55,8 @@ Dynamic: summary
54
55
  It combines **units**, **scales**, and **dimensions** into a composable algebra that supports:
55
56
 
56
57
  - Dimensional analysis through `Number` and `Ratio`
57
- - Scale-aware arithmetic and conversions
58
- - Metric and binary prefixes (`kilo`, `kibi`, `micro`, `mebi`, ect.)
58
+ - Scale-aware arithmetic via `UnitFactor` and `UnitProduct`
59
+ - Metric and binary prefixes (`kilo`, `kibi`, `micro`, `mebi`, etc.)
59
60
  - A clean foundation for physics, chemistry, data modeling, and beyond
60
61
 
61
62
  Think of it as **`decimal.Decimal` for the physical world** — precise, predictable, and type-safe.
@@ -69,20 +70,22 @@ The crux of this tiny library is to provide abstractions that simplify the answe
69
70
  To best answer this question, we turn to an age-old technique ([dimensional analysis](https://en.wikipedia.org/wiki/Dimensional_analysis)) which essentially allows for the solution to be written as a product of ratios. `ucon` comes equipped with some useful primitives:
70
71
  | Type | Defined In | Purpose | Typical Use Cases |
71
72
  | ----------------------------- | --------------------------------------- | --------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
72
- | **`Vector`** | `ucon.dimension` | Represents the exponent tuple of a physical quantitys base dimensions (e.g., T, L, M, I, Θ, J, N). | Internal representation of dimensional algebra; building derived quantities (e.g., area, velocity, force). |
73
- | **`Dimension`** | `ucon.dimension` | Encapsulates physical dimensions (e.g., length, time, mass) as algebraic combinations of vectors. | Enforcing dimensional consistency; defining relationships between quantities (e.g., length / time = velocity). |
74
- | **`Unit`** | `ucon.unit` | Represents a named, dimensioned measurement unit (e.g., meter, second, joule). | Attaching human-readable units to quantities; defining or composing new units (`newton = kilogram * meter / second²`). |
73
+ | **`Vector`** | `ucon.algebra` | Represents the exponent tuple of a physical quantity's base dimensions (e.g., T, L, M, I, Θ, J, N). | Internal representation of dimensional algebra; building derived quantities (e.g., area, velocity, force). |
74
+ | **`Exponent`** | `ucon.algebra` | Represents base-power pairs (e.g., 10³, 2¹⁰) used by `Scale`. | Performing arithmetic on powers and bases; normalizing scales across conversions. |
75
+ | **`Dimension`** | `ucon.core` | Encapsulates physical dimensions (e.g., length, time, mass) as algebraic combinations of vectors. | Enforcing dimensional consistency; defining relationships between quantities (e.g., length / time = velocity). |
75
76
  | **`Scale`** | `ucon.core` | Encodes powers of base magnitudes (binary or decimal prefixes like kilo-, milli-, mebi-). | Adjusting numeric scale without changing dimension (e.g., kilometer ↔ meter, byte ↔ kibibyte). |
76
- | **`Exponent`** | `ucon.core` | Represents base-power pairs (e.g., 10³, 2¹⁰) used by `Scale`. | Performing arithmetic on powers and bases; normalizing scales across conversions. |
77
- | **`Number`** | `ucon.core` | Combines a numeric quantity with a unit and scale; the primary measurable type. | Performing arithmetic with units; converting between compatible units; representing physical quantities like 5 m/s. |
78
- | **`Ratio`** | `ucon.core` | Represents the division of two `Number` objects; captures relationships between quantities. | Expressing rates, densities, efficiencies (e.g., energy / time = power, length / time = velocity). |
79
- | **`units` module** | `ucon.units` | Defines canonical unit instances (SI and common derived units). | Quick access to standard physical units (`units.meter`, `units.second`, `units.newton`, etc.). | |
77
+ | **`Unit`** | `ucon.core` | An atomic, scale-free measurement symbol (e.g., meter, second, joule) with a `Dimension`. | Defining base units; serving as graph nodes for future conversions. |
78
+ | **`UnitFactor`** | `ucon.core` | Pairs a `Unit` with a `Scale` (e.g., kilo + gram = kg). Used as keys inside `UnitProduct`. | Preserving user-provided scale prefixes through algebraic operations. |
79
+ | **`UnitProduct`** | `ucon.core` | A product/quotient of `UnitFactor`s with exponent tracking and simplification. | Representing composite units like m/s, kg·m/s², kJ·h. |
80
+ | **`Number`** | `ucon.quantity` | Combines a numeric quantity with a unit; the primary measurable type. | Performing arithmetic with units; representing physical quantities like 5 m/s. |
81
+ | **`Ratio`** | `ucon.quantity` | Represents the division of two `Number` objects; captures relationships between quantities. | Expressing rates, densities, efficiencies (e.g., energy / time = power, length / time = velocity). |
82
+ | **`units` module** | `ucon.units` | Defines canonical unit instances (SI and common derived units). | Quick access to standard physical units (`units.meter`, `units.second`, `units.newton`, etc.). |
80
83
 
81
84
  ### Under the Hood
82
85
 
83
86
  `ucon` models unit math through a hierarchy where each layer builds on the last:
84
87
 
85
- <img src=https://gist.githubusercontent.com/withtwoemms/429d2ca1f979865aa80a2658bf9efa32/raw/f3518d37445301950026fc9ffd1bd062768005fe/ucon.data-model.png align="center" alt="ucon Data Model" width=600/>
88
+ <img src=https://gist.githubusercontent.com/withtwoemms/429d2ca1f979865aa80a2658bf9efa32/raw/f24134c362829dc72e7dff18bfcaa24b9be01b54/ucon.data-model_v035.png align="center" alt="ucon Data Model" width=600/>
86
89
 
87
90
  ## Why `ucon`?
88
91
 
@@ -90,24 +93,22 @@ Python already has mature libraries for handling units and physical quantities
90
93
 
91
94
  | Library | Focus | Limitation |
92
95
  | --------- | ------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
93
- | **Pint** | Runtime unit conversion and compatibility checking | Treats quantities as decorated numbers — conversions work, but the algebra behind them isnt inspectable or type-safe. |
96
+ | **Pint** | Runtime unit conversion and compatibility checking | Treats quantities as decorated numbers — conversions work, but the algebra behind them isn't inspectable or type-safe. |
94
97
  | **SymPy** | Symbolic algebra and simplification of unit expressions | Excellent for symbolic reasoning, but not designed for runtime validation, conversion, or serialization. |
95
98
  | **Unum** | Unit-aware arithmetic and unit propagation | Tracks units through arithmetic but lacks explicit dimensional algebra, conversion taxonomy, or runtime introspection. |
96
99
 
97
100
  Together, these tools can _use_ units, but none can explicitly represent and verify the relationships between units and dimensions.
98
101
 
99
- Thats the gap `ucon` fills.
102
+ That's the gap `ucon` fills.
100
103
 
101
104
  It treats units, dimensions, and scales as first-class objects and builds a composable algebra around them.
102
105
  This allows you to:
103
106
  - Represent dimensional meaning explicitly (`Dimension`, `Vector`);
104
107
  - Compose and compute with type-safe, introspectable quantities (`Unit`, `Number`);
105
- - Perform reversible, declarative conversions (standard, linear, affine, nonlinear);
106
- - Serialize and validate measurements with Pydantic integration;
107
108
  - Extend the system with custom unit registries and conversion families.
108
109
 
109
110
  Where Pint, Unum, and SymPy focus on _how_ to compute with units,
110
- `ucon` focuses on why those computations make sense. Every operation checks the dimensional structure, _not just the unit labels_. This means ucon doesnt just track names: it enforces physics:
111
+ `ucon` focuses on why those computations make sense. Every operation checks the dimensional structure, _not just the unit labels_. This means ucon doesn't just track names: it enforces physics:
111
112
  ```python
112
113
  from ucon import Number, units
113
114
 
@@ -135,39 +136,50 @@ This sort of dimensional analysis:
135
136
  ```
136
137
  becomes straightforward when you define a measurement:
137
138
  ```python
138
- from ucon import Number, Scale, Units, Ratio
139
+ from ucon import Number, Scale, units
140
+ from ucon.quantity import Ratio
139
141
 
140
142
  # Two milliliters of bromine
141
- two_mL_bromine = Number(unit=Units.liter, scale=Scale.milli, quantity=2)
143
+ mL = Scale.milli * units.liter
144
+ two_mL_bromine = Number(quantity=2, unit=mL)
142
145
 
143
146
  # Density of bromine: 3.119 g/mL
144
147
  bromine_density = Ratio(
145
- numerator=Number(unit=Units.gram, quantity=3.119),
146
- denominator=Number(unit=Units.liter, scale=Scale.milli),
148
+ numerator=Number(unit=units.gram, quantity=3.119),
149
+ denominator=Number(unit=mL),
147
150
  )
148
151
 
149
152
  # Multiply to find mass
150
- grams_bromine = two_mL_bromine * bromine_density
151
- print(grams_bromine) # <6.238 gram>
153
+ grams_bromine = bromine_density.evaluate() * two_mL_bromine
154
+ print(grams_bromine) # <6.238 g>
152
155
  ```
153
156
 
154
- Scale conversion is automatic and precise:
155
-
157
+ Scale prefixes compose naturally:
156
158
  ```python
157
- grams_bromine.to(Scale.milli) # <6238.0 milligram>
158
- grams_bromine.to(Scale.kibi) # <0.006091796875 kibigram>
159
+ km = Scale.kilo * units.meter # UnitProduct with kilo-scaled meter
160
+ mg = Scale.milli * units.gram # UnitProduct with milli-scaled gram
161
+
162
+ print(km.shorthand) # 'km'
163
+ print(mg.shorthand) # 'mg'
164
+
165
+ # Scale arithmetic
166
+ print(km.fold_scale()) # 1000.0
167
+ print(mg.fold_scale()) # 0.001
159
168
  ```
160
169
 
170
+ > **Note:** Unit _conversions_ (e.g., `number.to(units.inch)`) are planned for v0.4.x
171
+ > via the `ConversionGraph` abstraction. See [ROADMAP.md](./ROADMAP.md).
172
+
161
173
  ---
162
174
 
163
175
  ## Roadmap Highlights
164
176
 
165
- | Version | Theme | Focus |
166
- |----------|-------|--------|
167
- | [**0.3.x**](https://github.com/withtwoemms/ucon/milestone/1) | Primitive Type Refinement | Unified algebraic foundation |
168
- | [**0.4.x**](https://github.com/withtwoemms/ucon/milestone/2) | Conversion System | Linear & affine conversions |
169
- | [**0.6.x**](https://github.com/withtwoemms/ucon/milestone/4) | Nonlinear / Specialized Units | Decibel, Percent, pH |
170
- | [**0.8.x**](https://github.com/withtwoemms/ucon/milestone/6) | Pydantic Integration | Type-safe quantity validation |
177
+ | Version | Theme | Focus | Status |
178
+ |----------|-------|--------|--------|
179
+ | **0.3.5** | Dimensional Algebra | Unit/Scale separation, `UnitFactor`, `UnitProduct` | ✅ Complete |
180
+ | [**0.4.x**](https://github.com/withtwoemms/ucon/milestone/2) | Conversion System | `ConversionGraph`, `Number.to()` | 🚧 Up Next |
181
+ | [**0.6.x**](https://github.com/withtwoemms/ucon/milestone/4) | Nonlinear / Specialized Units | Decibel, Percent, pH | ⏳ Planned |
182
+ | [**0.8.x**](https://github.com/withtwoemms/ucon/milestone/6) | Pydantic Integration | Type-safe quantity validation | ⏳ Planned |
171
183
 
172
184
  See full roadmap: [ROADMAP.md](./ROADMAP.md)
173
185
 
@@ -180,13 +192,13 @@ Ensure `nox` is installed.
180
192
  ```
181
193
  pip install -r requirements.txt
182
194
  ```
183
- Then run the full test suite (agains all supported python versions) before committing:
195
+ Then run the full test suite (against all supported python versions) before committing:
184
196
 
185
197
  ```bash
186
198
  nox -s test
187
199
  ```
188
200
  ---
189
201
 
190
- > If it can be measured, it can be represented.
202
+ > "If it can be measured, it can be represented.
191
203
  If it can be represented, it can be validated.
192
- If it can be validated, it can be trusted.”
204
+ If it can be validated, it can be trusted."
@@ -18,8 +18,8 @@
18
18
  It combines **units**, **scales**, and **dimensions** into a composable algebra that supports:
19
19
 
20
20
  - Dimensional analysis through `Number` and `Ratio`
21
- - Scale-aware arithmetic and conversions
22
- - Metric and binary prefixes (`kilo`, `kibi`, `micro`, `mebi`, ect.)
21
+ - Scale-aware arithmetic via `UnitFactor` and `UnitProduct`
22
+ - Metric and binary prefixes (`kilo`, `kibi`, `micro`, `mebi`, etc.)
23
23
  - A clean foundation for physics, chemistry, data modeling, and beyond
24
24
 
25
25
  Think of it as **`decimal.Decimal` for the physical world** — precise, predictable, and type-safe.
@@ -33,20 +33,22 @@ The crux of this tiny library is to provide abstractions that simplify the answe
33
33
  To best answer this question, we turn to an age-old technique ([dimensional analysis](https://en.wikipedia.org/wiki/Dimensional_analysis)) which essentially allows for the solution to be written as a product of ratios. `ucon` comes equipped with some useful primitives:
34
34
  | Type | Defined In | Purpose | Typical Use Cases |
35
35
  | ----------------------------- | --------------------------------------- | --------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
36
- | **`Vector`** | `ucon.dimension` | Represents the exponent tuple of a physical quantitys base dimensions (e.g., T, L, M, I, Θ, J, N). | Internal representation of dimensional algebra; building derived quantities (e.g., area, velocity, force). |
37
- | **`Dimension`** | `ucon.dimension` | Encapsulates physical dimensions (e.g., length, time, mass) as algebraic combinations of vectors. | Enforcing dimensional consistency; defining relationships between quantities (e.g., length / time = velocity). |
38
- | **`Unit`** | `ucon.unit` | Represents a named, dimensioned measurement unit (e.g., meter, second, joule). | Attaching human-readable units to quantities; defining or composing new units (`newton = kilogram * meter / second²`). |
36
+ | **`Vector`** | `ucon.algebra` | Represents the exponent tuple of a physical quantity's base dimensions (e.g., T, L, M, I, Θ, J, N). | Internal representation of dimensional algebra; building derived quantities (e.g., area, velocity, force). |
37
+ | **`Exponent`** | `ucon.algebra` | Represents base-power pairs (e.g., 10³, 2¹⁰) used by `Scale`. | Performing arithmetic on powers and bases; normalizing scales across conversions. |
38
+ | **`Dimension`** | `ucon.core` | Encapsulates physical dimensions (e.g., length, time, mass) as algebraic combinations of vectors. | Enforcing dimensional consistency; defining relationships between quantities (e.g., length / time = velocity). |
39
39
  | **`Scale`** | `ucon.core` | Encodes powers of base magnitudes (binary or decimal prefixes like kilo-, milli-, mebi-). | Adjusting numeric scale without changing dimension (e.g., kilometer ↔ meter, byte ↔ kibibyte). |
40
- | **`Exponent`** | `ucon.core` | Represents base-power pairs (e.g., 10³, 2¹⁰) used by `Scale`. | Performing arithmetic on powers and bases; normalizing scales across conversions. |
41
- | **`Number`** | `ucon.core` | Combines a numeric quantity with a unit and scale; the primary measurable type. | Performing arithmetic with units; converting between compatible units; representing physical quantities like 5 m/s. |
42
- | **`Ratio`** | `ucon.core` | Represents the division of two `Number` objects; captures relationships between quantities. | Expressing rates, densities, efficiencies (e.g., energy / time = power, length / time = velocity). |
43
- | **`units` module** | `ucon.units` | Defines canonical unit instances (SI and common derived units). | Quick access to standard physical units (`units.meter`, `units.second`, `units.newton`, etc.). | |
40
+ | **`Unit`** | `ucon.core` | An atomic, scale-free measurement symbol (e.g., meter, second, joule) with a `Dimension`. | Defining base units; serving as graph nodes for future conversions. |
41
+ | **`UnitFactor`** | `ucon.core` | Pairs a `Unit` with a `Scale` (e.g., kilo + gram = kg). Used as keys inside `UnitProduct`. | Preserving user-provided scale prefixes through algebraic operations. |
42
+ | **`UnitProduct`** | `ucon.core` | A product/quotient of `UnitFactor`s with exponent tracking and simplification. | Representing composite units like m/s, kg·m/s², kJ·h. |
43
+ | **`Number`** | `ucon.quantity` | Combines a numeric quantity with a unit; the primary measurable type. | Performing arithmetic with units; representing physical quantities like 5 m/s. |
44
+ | **`Ratio`** | `ucon.quantity` | Represents the division of two `Number` objects; captures relationships between quantities. | Expressing rates, densities, efficiencies (e.g., energy / time = power, length / time = velocity). |
45
+ | **`units` module** | `ucon.units` | Defines canonical unit instances (SI and common derived units). | Quick access to standard physical units (`units.meter`, `units.second`, `units.newton`, etc.). |
44
46
 
45
47
  ### Under the Hood
46
48
 
47
49
  `ucon` models unit math through a hierarchy where each layer builds on the last:
48
50
 
49
- <img src=https://gist.githubusercontent.com/withtwoemms/429d2ca1f979865aa80a2658bf9efa32/raw/f3518d37445301950026fc9ffd1bd062768005fe/ucon.data-model.png align="center" alt="ucon Data Model" width=600/>
51
+ <img src=https://gist.githubusercontent.com/withtwoemms/429d2ca1f979865aa80a2658bf9efa32/raw/f24134c362829dc72e7dff18bfcaa24b9be01b54/ucon.data-model_v035.png align="center" alt="ucon Data Model" width=600/>
50
52
 
51
53
  ## Why `ucon`?
52
54
 
@@ -54,24 +56,22 @@ Python already has mature libraries for handling units and physical quantities
54
56
 
55
57
  | Library | Focus | Limitation |
56
58
  | --------- | ------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
57
- | **Pint** | Runtime unit conversion and compatibility checking | Treats quantities as decorated numbers — conversions work, but the algebra behind them isnt inspectable or type-safe. |
59
+ | **Pint** | Runtime unit conversion and compatibility checking | Treats quantities as decorated numbers — conversions work, but the algebra behind them isn't inspectable or type-safe. |
58
60
  | **SymPy** | Symbolic algebra and simplification of unit expressions | Excellent for symbolic reasoning, but not designed for runtime validation, conversion, or serialization. |
59
61
  | **Unum** | Unit-aware arithmetic and unit propagation | Tracks units through arithmetic but lacks explicit dimensional algebra, conversion taxonomy, or runtime introspection. |
60
62
 
61
63
  Together, these tools can _use_ units, but none can explicitly represent and verify the relationships between units and dimensions.
62
64
 
63
- Thats the gap `ucon` fills.
65
+ That's the gap `ucon` fills.
64
66
 
65
67
  It treats units, dimensions, and scales as first-class objects and builds a composable algebra around them.
66
68
  This allows you to:
67
69
  - Represent dimensional meaning explicitly (`Dimension`, `Vector`);
68
70
  - Compose and compute with type-safe, introspectable quantities (`Unit`, `Number`);
69
- - Perform reversible, declarative conversions (standard, linear, affine, nonlinear);
70
- - Serialize and validate measurements with Pydantic integration;
71
71
  - Extend the system with custom unit registries and conversion families.
72
72
 
73
73
  Where Pint, Unum, and SymPy focus on _how_ to compute with units,
74
- `ucon` focuses on why those computations make sense. Every operation checks the dimensional structure, _not just the unit labels_. This means ucon doesnt just track names: it enforces physics:
74
+ `ucon` focuses on why those computations make sense. Every operation checks the dimensional structure, _not just the unit labels_. This means ucon doesn't just track names: it enforces physics:
75
75
  ```python
76
76
  from ucon import Number, units
77
77
 
@@ -99,39 +99,50 @@ This sort of dimensional analysis:
99
99
  ```
100
100
  becomes straightforward when you define a measurement:
101
101
  ```python
102
- from ucon import Number, Scale, Units, Ratio
102
+ from ucon import Number, Scale, units
103
+ from ucon.quantity import Ratio
103
104
 
104
105
  # Two milliliters of bromine
105
- two_mL_bromine = Number(unit=Units.liter, scale=Scale.milli, quantity=2)
106
+ mL = Scale.milli * units.liter
107
+ two_mL_bromine = Number(quantity=2, unit=mL)
106
108
 
107
109
  # Density of bromine: 3.119 g/mL
108
110
  bromine_density = Ratio(
109
- numerator=Number(unit=Units.gram, quantity=3.119),
110
- denominator=Number(unit=Units.liter, scale=Scale.milli),
111
+ numerator=Number(unit=units.gram, quantity=3.119),
112
+ denominator=Number(unit=mL),
111
113
  )
112
114
 
113
115
  # Multiply to find mass
114
- grams_bromine = two_mL_bromine * bromine_density
115
- print(grams_bromine) # <6.238 gram>
116
+ grams_bromine = bromine_density.evaluate() * two_mL_bromine
117
+ print(grams_bromine) # <6.238 g>
116
118
  ```
117
119
 
118
- Scale conversion is automatic and precise:
119
-
120
+ Scale prefixes compose naturally:
120
121
  ```python
121
- grams_bromine.to(Scale.milli) # <6238.0 milligram>
122
- grams_bromine.to(Scale.kibi) # <0.006091796875 kibigram>
122
+ km = Scale.kilo * units.meter # UnitProduct with kilo-scaled meter
123
+ mg = Scale.milli * units.gram # UnitProduct with milli-scaled gram
124
+
125
+ print(km.shorthand) # 'km'
126
+ print(mg.shorthand) # 'mg'
127
+
128
+ # Scale arithmetic
129
+ print(km.fold_scale()) # 1000.0
130
+ print(mg.fold_scale()) # 0.001
123
131
  ```
124
132
 
133
+ > **Note:** Unit _conversions_ (e.g., `number.to(units.inch)`) are planned for v0.4.x
134
+ > via the `ConversionGraph` abstraction. See [ROADMAP.md](./ROADMAP.md).
135
+
125
136
  ---
126
137
 
127
138
  ## Roadmap Highlights
128
139
 
129
- | Version | Theme | Focus |
130
- |----------|-------|--------|
131
- | [**0.3.x**](https://github.com/withtwoemms/ucon/milestone/1) | Primitive Type Refinement | Unified algebraic foundation |
132
- | [**0.4.x**](https://github.com/withtwoemms/ucon/milestone/2) | Conversion System | Linear & affine conversions |
133
- | [**0.6.x**](https://github.com/withtwoemms/ucon/milestone/4) | Nonlinear / Specialized Units | Decibel, Percent, pH |
134
- | [**0.8.x**](https://github.com/withtwoemms/ucon/milestone/6) | Pydantic Integration | Type-safe quantity validation |
140
+ | Version | Theme | Focus | Status |
141
+ |----------|-------|--------|--------|
142
+ | **0.3.5** | Dimensional Algebra | Unit/Scale separation, `UnitFactor`, `UnitProduct` | ✅ Complete |
143
+ | [**0.4.x**](https://github.com/withtwoemms/ucon/milestone/2) | Conversion System | `ConversionGraph`, `Number.to()` | 🚧 Up Next |
144
+ | [**0.6.x**](https://github.com/withtwoemms/ucon/milestone/4) | Nonlinear / Specialized Units | Decibel, Percent, pH | ⏳ Planned |
145
+ | [**0.8.x**](https://github.com/withtwoemms/ucon/milestone/6) | Pydantic Integration | Type-safe quantity validation | ⏳ Planned |
135
146
 
136
147
  See full roadmap: [ROADMAP.md](./ROADMAP.md)
137
148
 
@@ -144,13 +155,13 @@ Ensure `nox` is installed.
144
155
  ```
145
156
  pip install -r requirements.txt
146
157
  ```
147
- Then run the full test suite (agains all supported python versions) before committing:
158
+ Then run the full test suite (against all supported python versions) before committing:
148
159
 
149
160
  ```bash
150
161
  nox -s test
151
162
  ```
152
163
  ---
153
164
 
154
- > If it can be measured, it can be represented.
165
+ > "If it can be measured, it can be represented.
155
166
  If it can be represented, it can be validated.
156
- If it can be validated, it can be trusted.”
167
+ If it can be validated, it can be trusted."