qnty 0.0.1__tar.gz → 0.0.3__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.
- {qnty-0.0.1 → qnty-0.0.3}/PKG-INFO +109 -22
- {qnty-0.0.1 → qnty-0.0.3}/README.md +108 -22
- {qnty-0.0.1 → qnty-0.0.3}/pyproject.toml +3 -1
- qnty-0.0.3/src/qnty/__init__.py +175 -0
- qnty-0.0.3/src/qnty/dimension.py +184 -0
- qnty-0.0.3/src/qnty/equation.py +216 -0
- qnty-0.0.3/src/qnty/expression.py +480 -0
- qnty-0.0.3/src/qnty/prefixes.py +229 -0
- {qnty-0.0.1 → qnty-0.0.3}/src/qnty/unit.py +76 -8
- qnty-0.0.3/src/qnty/unit_types/base.py +47 -0
- qnty-0.0.3/src/qnty/units.py +8092 -0
- {qnty-0.0.1 → qnty-0.0.3}/src/qnty/variable.py +69 -29
- qnty-0.0.3/src/qnty/variable_types/__init__.py +0 -0
- qnty-0.0.3/src/qnty/variable_types/base.py +58 -0
- qnty-0.0.3/src/qnty/variable_types/expression_variable.py +68 -0
- qnty-0.0.3/src/qnty/variable_types/typed_variable.py +92 -0
- qnty-0.0.3/src/qnty/variables.py +2303 -0
- qnty-0.0.3/src/qnty/variables.pyi +6097 -0
- qnty-0.0.1/src/qnty/dimension.py +0 -85
- qnty-0.0.1/src/qnty/setters.py +0 -89
- qnty-0.0.1/src/qnty/units.py +0 -47
- qnty-0.0.1/src/qnty/variables.py +0 -31
- {qnty-0.0.1/src/qnty → qnty-0.0.3/src/qnty/unit_types}/__init__.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: qnty
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.3
|
4
4
|
Summary: High-performance unit system library for Python with dimensional safety and fast unit conversions
|
5
5
|
License: Apache-2.0
|
6
6
|
Keywords: units,dimensional analysis,engineering,physics,quantities,measurements
|
@@ -33,7 +33,7 @@ Description-Content-Type: text/markdown
|
|
33
33
|
|
34
34
|
**High-performance unit system library for Python with dimensional safety and fast unit conversions for engineering calculations.**
|
35
35
|
|
36
|
-
[](https://www.python.org/downloads/)
|
37
37
|
[](https://opensource.org/licenses/Apache-2.0)
|
38
38
|
[](https://pypi.org/project/qnty/)
|
39
39
|
|
@@ -43,7 +43,7 @@ Description-Content-Type: text/markdown
|
|
43
43
|
|
44
44
|
**📐 Accuracy Notice**: The authors are not responsible or liable for incorrect results, calculation errors, or any consequences arising from the use of this library. Always validate calculations independently using established engineering tools and practices.
|
45
45
|
|
46
|
-
**🚀 Learn from History**: Remember, even NASA's Mars Climate Orbiter had a $327 million oops moment due to unit conversion errors between metric and imperial systems. Don't let your project become the next cautionary tale - double-check everything!
|
46
|
+
**🚀 Learn from History**: Remember, even NASA's Mars Climate Orbiter had a $327 million oops moment due to unit conversion errors between metric and imperial systems. Don't let your project become the next cautionary tale - double-check everything!
|
47
47
|
|
48
48
|
*Use Qnty to help prevent unit errors, but always verify critical calculations through multiple methods.*
|
49
49
|
|
@@ -58,7 +58,9 @@ Qnty is designed around **type safety** and **performance optimization** using c
|
|
58
58
|
- **⚡ Zero-Cost Abstractions**: Optimized operations with `__slots__` and caching
|
59
59
|
- **🔗 Fluent API**: Intuitive method chaining for readable code
|
60
60
|
- **🧮 Engineering-Focused**: Built for real-world engineering calculations
|
61
|
-
-
|
61
|
+
- **🧬 Mathematical System**: Built-in equation solving and expression trees
|
62
|
+
- **📊 Comprehensive Testing**: 457 tests with performance benchmarks
|
63
|
+
- **🏗️ Clean Architecture**: Circular import-free design with strict dependency hierarchy
|
62
64
|
|
63
65
|
## 🚀 Quick Start
|
64
66
|
|
@@ -73,7 +75,7 @@ poetry add qnty
|
|
73
75
|
### Basic Usage
|
74
76
|
|
75
77
|
```python
|
76
|
-
from qnty
|
78
|
+
from qnty import Length, Pressure, Dimensionless
|
77
79
|
from qnty.variable import FastQuantity
|
78
80
|
from qnty.units import LengthUnits, PressureUnits
|
79
81
|
|
@@ -95,7 +97,7 @@ force = pressure * area # Automatic dimensional analysis
|
|
95
97
|
### Engineering Example
|
96
98
|
|
97
99
|
```python
|
98
|
-
from qnty
|
100
|
+
from qnty import Length, Pressure
|
99
101
|
|
100
102
|
# ASME pressure vessel calculation with mixed units
|
101
103
|
pressure = Pressure("internal_pressure")
|
@@ -112,47 +114,90 @@ thickness = (pressure.quantity * diameter.quantity) / (2 * stress.quantity)
|
|
112
114
|
print(f"Required thickness: {thickness}") # Automatically in correct units
|
113
115
|
```
|
114
116
|
|
117
|
+
### Mathematical Equations & Solving
|
118
|
+
|
119
|
+
```python
|
120
|
+
from qnty import Length, Pressure, Dimensionless
|
121
|
+
|
122
|
+
# Define engineering variables
|
123
|
+
T = Length("Wall Thickness", is_known=False) # Unknown to solve for
|
124
|
+
T_bar = Length(0.147, "inches", "Nominal Wall Thickness")
|
125
|
+
U_m = Dimensionless(0.125, "Mill Undertolerance")
|
126
|
+
|
127
|
+
# Create equation using fluent API: T = T_bar * (1 - U_m)
|
128
|
+
equation = T.equals(T_bar * (1 - U_m))
|
129
|
+
|
130
|
+
# Solve automatically
|
131
|
+
known_vars = {"T_bar": T_bar, "U_m": U_m}
|
132
|
+
result = equation.solve_for("T", known_vars)
|
133
|
+
print(f"Solved thickness: {result.quantity}") # 0.128625 inches
|
134
|
+
|
135
|
+
# Verify equation is satisfied
|
136
|
+
assert equation.check_residual(known_vars) is True
|
137
|
+
```
|
138
|
+
|
115
139
|
## 🏗️ Architecture
|
116
140
|
|
141
|
+
### Clean Dependency Design
|
142
|
+
|
143
|
+
Qnty features a carefully designed architecture that eliminates circular imports through a strict dependency hierarchy:
|
144
|
+
|
145
|
+
```python
|
146
|
+
variable → variables → expression → equation
|
147
|
+
```
|
148
|
+
|
149
|
+
This ensures clean type checking, maintainable code, and optimal performance throughout the system.
|
150
|
+
|
117
151
|
### Core Components
|
118
152
|
|
119
|
-
|
153
|
+
### 🔢 Dimensional System
|
154
|
+
|
120
155
|
- Prime number encoding for ultra-fast dimensional compatibility checks
|
121
156
|
- Zero-cost dimensional analysis at compile time
|
122
157
|
- Immutable dimension signatures for thread safety
|
123
158
|
|
124
|
-
|
159
|
+
### ⚙️ High-Performance Quantities
|
160
|
+
|
125
161
|
- `FastQuantity`: Optimized for engineering calculations with `__slots__`
|
126
162
|
- Cached SI factors and dimension signatures
|
127
163
|
- Fast-path optimizations for same-unit operations
|
128
164
|
|
129
|
-
|
130
|
-
|
165
|
+
### 🎯 Type-Safe Variables
|
166
|
+
|
167
|
+
- `Length`, `Pressure`, `Dimensionless`: Domain-specific variables with compile-time safety
|
131
168
|
- Fluent API with specialized setters
|
132
169
|
- Prevents dimensional errors at the type level
|
133
170
|
|
134
|
-
|
171
|
+
### 🔄 Smart Unit System
|
172
|
+
|
135
173
|
- Pre-computed conversion tables
|
136
174
|
- Automatic unit resolution for calculations
|
137
175
|
- Support for mixed-unit operations
|
138
176
|
|
177
|
+
### 🧬 Mathematical System
|
178
|
+
|
179
|
+
- Built-in equation solving with symbolic manipulation
|
180
|
+
- Expression trees for complex mathematical operations
|
181
|
+
- Automatic residual checking and validation
|
182
|
+
- Engineering equation support (ASME, pressure vessels, etc.)
|
183
|
+
|
139
184
|
## 📊 Performance
|
140
185
|
|
141
|
-
Qnty significantly outperforms other unit libraries with **
|
186
|
+
Qnty significantly outperforms other unit libraries with **18.9x average speedup** over Pint:
|
142
187
|
|
143
188
|
### Real Benchmark Results (μs per operation)
|
144
189
|
|
145
190
|
| Operation | Qnty | Pint | **Speedup** |
|
146
191
|
|-----------|------|------|-------------|
|
147
|
-
| Unit Conversion (m → mm) | 0.
|
148
|
-
| Mixed Unit Addition (mm + in) |
|
149
|
-
| Multiplication (m × m) | 0.
|
150
|
-
| Division (psi ÷ mm) |
|
151
|
-
| Complex ASME Equation |
|
152
|
-
| Type-Safe Variables |
|
153
|
-
| Chained Operations |
|
154
|
-
| Loop (10 additions) |
|
155
|
-
| **AVERAGE** | **
|
192
|
+
| Unit Conversion (m → mm) | 0.50 | 9.72 | **19.5x** |
|
193
|
+
| Mixed Unit Addition (mm + in) | 0.76 | 17.52 | **23.1x** |
|
194
|
+
| Multiplication (m × m) | 0.82 | 10.64 | **12.9x** |
|
195
|
+
| Division (psi ÷ mm) | 0.87 | 11.23 | **12.9x** |
|
196
|
+
| Complex ASME Equation | 4.07 | 106.17 | **26.1x** 🚀 |
|
197
|
+
| Type-Safe Variables | 0.98 | 9.65 | **9.8x** |
|
198
|
+
| Chained Operations | 1.83 | 42.22 | **23.1x** |
|
199
|
+
| Loop (10 additions) | 5.32 | 79.48 | **14.9x** |
|
200
|
+
| **AVERAGE** | **1.89** | **35.83** | **18.9x** 🏆 |
|
156
201
|
|
157
202
|
*Benchmarks performed on typical engineering calculations. Run `pytest tests/test_benchmark.py -v -s` to verify on your system.*
|
158
203
|
|
@@ -197,6 +242,44 @@ area = width.quantity * height.quantity
|
|
197
242
|
perimeter = 2 * (width.quantity + height.quantity)
|
198
243
|
```
|
199
244
|
|
245
|
+
### Equation Solving System
|
246
|
+
|
247
|
+
```python
|
248
|
+
from qnty import Length, Pressure, Dimensionless
|
249
|
+
|
250
|
+
# Multi-variable engineering equations
|
251
|
+
P = Pressure(90, "psi", "P") # Known
|
252
|
+
D = Length(0.84, "inches", "D") # Known
|
253
|
+
t = Length("t", is_known=False) # Unknown - solve for this
|
254
|
+
S = Pressure(20000, "psi", "S") # Known
|
255
|
+
|
256
|
+
# ASME pressure vessel equation: P = (S * t) / ((D/2) + 0.6*t)
|
257
|
+
# Rearranged to solve for t
|
258
|
+
equation = t.equals((P * D) / (2 * S - 1.2 * P))
|
259
|
+
|
260
|
+
# Solve automatically
|
261
|
+
known_variables = {"P": P, "D": D, "S": S}
|
262
|
+
thickness_result = equation.solve_for("t", known_variables)
|
263
|
+
print(f"Required thickness: {thickness_result.quantity}")
|
264
|
+
|
265
|
+
# Verify solution
|
266
|
+
assert equation.check_residual(known_variables) is True
|
267
|
+
```
|
268
|
+
|
269
|
+
### Import Strategy
|
270
|
+
|
271
|
+
Qnty provides a clean, minimal public API:
|
272
|
+
|
273
|
+
```python
|
274
|
+
# Preferred import style - clean public API
|
275
|
+
from qnty import Length, Pressure, Dimensionless
|
276
|
+
|
277
|
+
# Internal imports when needed for advanced usage
|
278
|
+
from qnty.variable import FastQuantity, TypeSafeVariable
|
279
|
+
from qnty.expression import Expression
|
280
|
+
from qnty.equation import Equation, EquationSystem
|
281
|
+
```
|
282
|
+
|
200
283
|
## 🔧 Development
|
201
284
|
|
202
285
|
### Setup Development Environment
|
@@ -221,6 +304,7 @@ python tests/test_benchmark.py
|
|
221
304
|
```bash
|
222
305
|
# Linting with ruff (200 character line length)
|
223
306
|
ruff check src/ tests/
|
307
|
+
ruff format src/ tests/
|
224
308
|
|
225
309
|
# Type checking
|
226
310
|
mypy src/qnty/
|
@@ -232,7 +316,9 @@ mypy src/qnty/
|
|
232
316
|
|
233
317
|
- **`FastQuantity`**: High-performance quantity with value and unit
|
234
318
|
- **`TypeSafeVariable`**: Base class for dimension-specific variables
|
235
|
-
- **`Length`**, **`Pressure`**: Specialized variables with fluent setters
|
319
|
+
- **`Length`**, **`Pressure`**, **`Dimensionless`**: Specialized variables with fluent setters
|
320
|
+
- **`Equation`**: Mathematical equations with solving capabilities
|
321
|
+
- **`Expression`**: Abstract base for mathematical expression trees
|
236
322
|
- **`DimensionSignature`**: Immutable dimension encoding system
|
237
323
|
- **`UnitConstant`**: Type-safe unit definitions
|
238
324
|
|
@@ -266,3 +352,4 @@ This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENS
|
|
266
352
|
---
|
267
353
|
|
268
354
|
**Ready to supercharge your engineering calculations?** Install Qnty today and experience the power of type-safe, high-performance unit handling! 🚀
|
355
|
+
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
**High-performance unit system library for Python with dimensional safety and fast unit conversions for engineering calculations.**
|
4
4
|
|
5
|
-
[](https://www.python.org/downloads/)
|
6
6
|
[](https://opensource.org/licenses/Apache-2.0)
|
7
7
|
[](https://pypi.org/project/qnty/)
|
8
8
|
|
@@ -12,7 +12,7 @@
|
|
12
12
|
|
13
13
|
**📐 Accuracy Notice**: The authors are not responsible or liable for incorrect results, calculation errors, or any consequences arising from the use of this library. Always validate calculations independently using established engineering tools and practices.
|
14
14
|
|
15
|
-
**🚀 Learn from History**: Remember, even NASA's Mars Climate Orbiter had a $327 million oops moment due to unit conversion errors between metric and imperial systems. Don't let your project become the next cautionary tale - double-check everything!
|
15
|
+
**🚀 Learn from History**: Remember, even NASA's Mars Climate Orbiter had a $327 million oops moment due to unit conversion errors between metric and imperial systems. Don't let your project become the next cautionary tale - double-check everything!
|
16
16
|
|
17
17
|
*Use Qnty to help prevent unit errors, but always verify critical calculations through multiple methods.*
|
18
18
|
|
@@ -27,7 +27,9 @@ Qnty is designed around **type safety** and **performance optimization** using c
|
|
27
27
|
- **⚡ Zero-Cost Abstractions**: Optimized operations with `__slots__` and caching
|
28
28
|
- **🔗 Fluent API**: Intuitive method chaining for readable code
|
29
29
|
- **🧮 Engineering-Focused**: Built for real-world engineering calculations
|
30
|
-
-
|
30
|
+
- **🧬 Mathematical System**: Built-in equation solving and expression trees
|
31
|
+
- **📊 Comprehensive Testing**: 457 tests with performance benchmarks
|
32
|
+
- **🏗️ Clean Architecture**: Circular import-free design with strict dependency hierarchy
|
31
33
|
|
32
34
|
## 🚀 Quick Start
|
33
35
|
|
@@ -42,7 +44,7 @@ poetry add qnty
|
|
42
44
|
### Basic Usage
|
43
45
|
|
44
46
|
```python
|
45
|
-
from qnty
|
47
|
+
from qnty import Length, Pressure, Dimensionless
|
46
48
|
from qnty.variable import FastQuantity
|
47
49
|
from qnty.units import LengthUnits, PressureUnits
|
48
50
|
|
@@ -64,7 +66,7 @@ force = pressure * area # Automatic dimensional analysis
|
|
64
66
|
### Engineering Example
|
65
67
|
|
66
68
|
```python
|
67
|
-
from qnty
|
69
|
+
from qnty import Length, Pressure
|
68
70
|
|
69
71
|
# ASME pressure vessel calculation with mixed units
|
70
72
|
pressure = Pressure("internal_pressure")
|
@@ -81,47 +83,90 @@ thickness = (pressure.quantity * diameter.quantity) / (2 * stress.quantity)
|
|
81
83
|
print(f"Required thickness: {thickness}") # Automatically in correct units
|
82
84
|
```
|
83
85
|
|
86
|
+
### Mathematical Equations & Solving
|
87
|
+
|
88
|
+
```python
|
89
|
+
from qnty import Length, Pressure, Dimensionless
|
90
|
+
|
91
|
+
# Define engineering variables
|
92
|
+
T = Length("Wall Thickness", is_known=False) # Unknown to solve for
|
93
|
+
T_bar = Length(0.147, "inches", "Nominal Wall Thickness")
|
94
|
+
U_m = Dimensionless(0.125, "Mill Undertolerance")
|
95
|
+
|
96
|
+
# Create equation using fluent API: T = T_bar * (1 - U_m)
|
97
|
+
equation = T.equals(T_bar * (1 - U_m))
|
98
|
+
|
99
|
+
# Solve automatically
|
100
|
+
known_vars = {"T_bar": T_bar, "U_m": U_m}
|
101
|
+
result = equation.solve_for("T", known_vars)
|
102
|
+
print(f"Solved thickness: {result.quantity}") # 0.128625 inches
|
103
|
+
|
104
|
+
# Verify equation is satisfied
|
105
|
+
assert equation.check_residual(known_vars) is True
|
106
|
+
```
|
107
|
+
|
84
108
|
## 🏗️ Architecture
|
85
109
|
|
110
|
+
### Clean Dependency Design
|
111
|
+
|
112
|
+
Qnty features a carefully designed architecture that eliminates circular imports through a strict dependency hierarchy:
|
113
|
+
|
114
|
+
```python
|
115
|
+
variable → variables → expression → equation
|
116
|
+
```
|
117
|
+
|
118
|
+
This ensures clean type checking, maintainable code, and optimal performance throughout the system.
|
119
|
+
|
86
120
|
### Core Components
|
87
121
|
|
88
|
-
|
122
|
+
### 🔢 Dimensional System
|
123
|
+
|
89
124
|
- Prime number encoding for ultra-fast dimensional compatibility checks
|
90
125
|
- Zero-cost dimensional analysis at compile time
|
91
126
|
- Immutable dimension signatures for thread safety
|
92
127
|
|
93
|
-
|
128
|
+
### ⚙️ High-Performance Quantities
|
129
|
+
|
94
130
|
- `FastQuantity`: Optimized for engineering calculations with `__slots__`
|
95
131
|
- Cached SI factors and dimension signatures
|
96
132
|
- Fast-path optimizations for same-unit operations
|
97
133
|
|
98
|
-
|
99
|
-
|
134
|
+
### 🎯 Type-Safe Variables
|
135
|
+
|
136
|
+
- `Length`, `Pressure`, `Dimensionless`: Domain-specific variables with compile-time safety
|
100
137
|
- Fluent API with specialized setters
|
101
138
|
- Prevents dimensional errors at the type level
|
102
139
|
|
103
|
-
|
140
|
+
### 🔄 Smart Unit System
|
141
|
+
|
104
142
|
- Pre-computed conversion tables
|
105
143
|
- Automatic unit resolution for calculations
|
106
144
|
- Support for mixed-unit operations
|
107
145
|
|
146
|
+
### 🧬 Mathematical System
|
147
|
+
|
148
|
+
- Built-in equation solving with symbolic manipulation
|
149
|
+
- Expression trees for complex mathematical operations
|
150
|
+
- Automatic residual checking and validation
|
151
|
+
- Engineering equation support (ASME, pressure vessels, etc.)
|
152
|
+
|
108
153
|
## 📊 Performance
|
109
154
|
|
110
|
-
Qnty significantly outperforms other unit libraries with **
|
155
|
+
Qnty significantly outperforms other unit libraries with **18.9x average speedup** over Pint:
|
111
156
|
|
112
157
|
### Real Benchmark Results (μs per operation)
|
113
158
|
|
114
159
|
| Operation | Qnty | Pint | **Speedup** |
|
115
160
|
|-----------|------|------|-------------|
|
116
|
-
| Unit Conversion (m → mm) | 0.
|
117
|
-
| Mixed Unit Addition (mm + in) |
|
118
|
-
| Multiplication (m × m) | 0.
|
119
|
-
| Division (psi ÷ mm) |
|
120
|
-
| Complex ASME Equation |
|
121
|
-
| Type-Safe Variables |
|
122
|
-
| Chained Operations |
|
123
|
-
| Loop (10 additions) |
|
124
|
-
| **AVERAGE** | **
|
161
|
+
| Unit Conversion (m → mm) | 0.50 | 9.72 | **19.5x** |
|
162
|
+
| Mixed Unit Addition (mm + in) | 0.76 | 17.52 | **23.1x** |
|
163
|
+
| Multiplication (m × m) | 0.82 | 10.64 | **12.9x** |
|
164
|
+
| Division (psi ÷ mm) | 0.87 | 11.23 | **12.9x** |
|
165
|
+
| Complex ASME Equation | 4.07 | 106.17 | **26.1x** 🚀 |
|
166
|
+
| Type-Safe Variables | 0.98 | 9.65 | **9.8x** |
|
167
|
+
| Chained Operations | 1.83 | 42.22 | **23.1x** |
|
168
|
+
| Loop (10 additions) | 5.32 | 79.48 | **14.9x** |
|
169
|
+
| **AVERAGE** | **1.89** | **35.83** | **18.9x** 🏆 |
|
125
170
|
|
126
171
|
*Benchmarks performed on typical engineering calculations. Run `pytest tests/test_benchmark.py -v -s` to verify on your system.*
|
127
172
|
|
@@ -166,6 +211,44 @@ area = width.quantity * height.quantity
|
|
166
211
|
perimeter = 2 * (width.quantity + height.quantity)
|
167
212
|
```
|
168
213
|
|
214
|
+
### Equation Solving System
|
215
|
+
|
216
|
+
```python
|
217
|
+
from qnty import Length, Pressure, Dimensionless
|
218
|
+
|
219
|
+
# Multi-variable engineering equations
|
220
|
+
P = Pressure(90, "psi", "P") # Known
|
221
|
+
D = Length(0.84, "inches", "D") # Known
|
222
|
+
t = Length("t", is_known=False) # Unknown - solve for this
|
223
|
+
S = Pressure(20000, "psi", "S") # Known
|
224
|
+
|
225
|
+
# ASME pressure vessel equation: P = (S * t) / ((D/2) + 0.6*t)
|
226
|
+
# Rearranged to solve for t
|
227
|
+
equation = t.equals((P * D) / (2 * S - 1.2 * P))
|
228
|
+
|
229
|
+
# Solve automatically
|
230
|
+
known_variables = {"P": P, "D": D, "S": S}
|
231
|
+
thickness_result = equation.solve_for("t", known_variables)
|
232
|
+
print(f"Required thickness: {thickness_result.quantity}")
|
233
|
+
|
234
|
+
# Verify solution
|
235
|
+
assert equation.check_residual(known_variables) is True
|
236
|
+
```
|
237
|
+
|
238
|
+
### Import Strategy
|
239
|
+
|
240
|
+
Qnty provides a clean, minimal public API:
|
241
|
+
|
242
|
+
```python
|
243
|
+
# Preferred import style - clean public API
|
244
|
+
from qnty import Length, Pressure, Dimensionless
|
245
|
+
|
246
|
+
# Internal imports when needed for advanced usage
|
247
|
+
from qnty.variable import FastQuantity, TypeSafeVariable
|
248
|
+
from qnty.expression import Expression
|
249
|
+
from qnty.equation import Equation, EquationSystem
|
250
|
+
```
|
251
|
+
|
169
252
|
## 🔧 Development
|
170
253
|
|
171
254
|
### Setup Development Environment
|
@@ -190,6 +273,7 @@ python tests/test_benchmark.py
|
|
190
273
|
```bash
|
191
274
|
# Linting with ruff (200 character line length)
|
192
275
|
ruff check src/ tests/
|
276
|
+
ruff format src/ tests/
|
193
277
|
|
194
278
|
# Type checking
|
195
279
|
mypy src/qnty/
|
@@ -201,7 +285,9 @@ mypy src/qnty/
|
|
201
285
|
|
202
286
|
- **`FastQuantity`**: High-performance quantity with value and unit
|
203
287
|
- **`TypeSafeVariable`**: Base class for dimension-specific variables
|
204
|
-
- **`Length`**, **`Pressure`**: Specialized variables with fluent setters
|
288
|
+
- **`Length`**, **`Pressure`**, **`Dimensionless`**: Specialized variables with fluent setters
|
289
|
+
- **`Equation`**: Mathematical equations with solving capabilities
|
290
|
+
- **`Expression`**: Abstract base for mathematical expression trees
|
205
291
|
- **`DimensionSignature`**: Immutable dimension encoding system
|
206
292
|
- **`UnitConstant`**: Type-safe unit definitions
|
207
293
|
|
@@ -234,4 +320,4 @@ This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENS
|
|
234
320
|
|
235
321
|
---
|
236
322
|
|
237
|
-
**Ready to supercharge your engineering calculations?** Install Qnty today and experience the power of type-safe, high-performance unit handling! 🚀
|
323
|
+
**Ready to supercharge your engineering calculations?** Install Qnty today and experience the power of type-safe, high-performance unit handling! 🚀
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[project]
|
2
2
|
name = "qnty"
|
3
|
-
version = "0.0.
|
3
|
+
version = "0.0.3"
|
4
4
|
description = "High-performance unit system library for Python with dimensional safety and fast unit conversions"
|
5
5
|
readme = "README.md"
|
6
6
|
license = { text = "Apache-2.0" }
|
@@ -63,6 +63,8 @@ select = [
|
|
63
63
|
]
|
64
64
|
ignore = [
|
65
65
|
"E501", # line too long (handled by line-length)
|
66
|
+
"B018", # no-else-return
|
67
|
+
"W293", # blank line contains whitespace
|
66
68
|
]
|
67
69
|
|
68
70
|
[tool.pytest.ini_options]
|
@@ -0,0 +1,175 @@
|
|
1
|
+
"""
|
2
|
+
Qnty - High-Performance Unit System for Engineering
|
3
|
+
====================================================
|
4
|
+
|
5
|
+
A fast, type-safe unit system library for Python with dimensional safety
|
6
|
+
and optimized unit conversions for engineering calculations.
|
7
|
+
"""
|
8
|
+
|
9
|
+
from .dimension import BaseDimension, DimensionSignature
|
10
|
+
from .equation import Equation
|
11
|
+
from .expression import Expression
|
12
|
+
from .unit import registry
|
13
|
+
from .units import register_all_units
|
14
|
+
from .variable import FastQuantity, TypeSafeSetter, TypeSafeVariable
|
15
|
+
from .variables import (
|
16
|
+
AbsorbedDose,
|
17
|
+
Acceleration,
|
18
|
+
ActivationEnergy,
|
19
|
+
AmountOfSubstance,
|
20
|
+
AnglePlane,
|
21
|
+
AngleSolid,
|
22
|
+
AngularAcceleration,
|
23
|
+
AngularMomentum,
|
24
|
+
Area,
|
25
|
+
AreaPerUnitVolume,
|
26
|
+
AtomicWeight,
|
27
|
+
Concentration,
|
28
|
+
DynamicFluidity,
|
29
|
+
ElectricCapacitance,
|
30
|
+
ElectricCharge,
|
31
|
+
ElectricCurrentIntensity,
|
32
|
+
ElectricDipoleMoment,
|
33
|
+
ElectricFieldStrength,
|
34
|
+
ElectricInductance,
|
35
|
+
ElectricPotential,
|
36
|
+
ElectricResistance,
|
37
|
+
ElectricalConductance,
|
38
|
+
ElectricalPermittivity,
|
39
|
+
ElectricalResistivity,
|
40
|
+
EnergyFlux,
|
41
|
+
EnergyHeatWork,
|
42
|
+
EnergyPerUnitArea,
|
43
|
+
Force,
|
44
|
+
ForceBody,
|
45
|
+
ForcePerUnitMass,
|
46
|
+
FrequencyVoltageRatio,
|
47
|
+
FuelConsumption,
|
48
|
+
HeatOfCombustion,
|
49
|
+
HeatOfFusion,
|
50
|
+
HeatOfVaporization,
|
51
|
+
HeatTransferCoefficient,
|
52
|
+
Illuminance,
|
53
|
+
KineticEnergyOfTurbulence,
|
54
|
+
Length,
|
55
|
+
LinearMassDensity,
|
56
|
+
LinearMomentum,
|
57
|
+
LuminanceSelf,
|
58
|
+
LuminousFlux,
|
59
|
+
LuminousIntensity,
|
60
|
+
MagneticField,
|
61
|
+
MagneticFlux,
|
62
|
+
MagneticInductionFieldStrength,
|
63
|
+
MagneticMoment,
|
64
|
+
MagneticPermeability,
|
65
|
+
MagnetomotiveForce,
|
66
|
+
Mass,
|
67
|
+
MassDensity,
|
68
|
+
MassFlowRate,
|
69
|
+
MassFlux,
|
70
|
+
MassFractionOfI,
|
71
|
+
MassTransferCoefficient,
|
72
|
+
MolalityOfSoluteI,
|
73
|
+
MolarConcentrationByMass,
|
74
|
+
MolarFlowRate,
|
75
|
+
MolarFlux,
|
76
|
+
MolarHeatCapacity,
|
77
|
+
MolarityOfI,
|
78
|
+
MoleFractionOfI,
|
79
|
+
MomentOfInertia,
|
80
|
+
MomentumFlowRate,
|
81
|
+
MomentumFlux,
|
82
|
+
NormalityOfSolution,
|
83
|
+
ParticleDensity,
|
84
|
+
Permeability,
|
85
|
+
PhotonEmissionRate,
|
86
|
+
PowerPerUnitMass,
|
87
|
+
PowerPerUnitVolume,
|
88
|
+
PowerThermalDuty,
|
89
|
+
Pressure,
|
90
|
+
RadiationDoseEquivalent,
|
91
|
+
RadiationExposure,
|
92
|
+
Radioactivity,
|
93
|
+
SecondMomentOfArea,
|
94
|
+
SecondRadiationConstantPlanck,
|
95
|
+
SpecificEnthalpy,
|
96
|
+
SpecificGravity,
|
97
|
+
SpecificHeatCapacityConstantPressure,
|
98
|
+
SpecificLength,
|
99
|
+
SpecificSurface,
|
100
|
+
SpecificVolume,
|
101
|
+
Stress,
|
102
|
+
SurfaceMassDensity,
|
103
|
+
SurfaceTension,
|
104
|
+
Temperature,
|
105
|
+
ThermalConductivity,
|
106
|
+
Time,
|
107
|
+
Torque,
|
108
|
+
TurbulenceEnergyDissipationRate,
|
109
|
+
VelocityAngular,
|
110
|
+
VelocityLinear,
|
111
|
+
ViscosityDynamic,
|
112
|
+
ViscosityKinematic,
|
113
|
+
Volume,
|
114
|
+
VolumeFractionOfI,
|
115
|
+
VolumetricCalorificHeatingValue,
|
116
|
+
VolumetricCoefficientOfExpansion,
|
117
|
+
VolumetricFlowRate,
|
118
|
+
VolumetricFlux,
|
119
|
+
VolumetricMassFlowRate,
|
120
|
+
Wavenumber
|
121
|
+
)
|
122
|
+
|
123
|
+
# Register all units to the global registry
|
124
|
+
register_all_units(registry)
|
125
|
+
|
126
|
+
# Finalize registry after all registrations
|
127
|
+
registry.finalize_registration()
|
128
|
+
|
129
|
+
# Version information
|
130
|
+
__version__ = "0.0.3"
|
131
|
+
|
132
|
+
# Define public API
|
133
|
+
__all__ = [
|
134
|
+
# Core variable types (most commonly used)
|
135
|
+
"Length", "Pressure", "Temperature", "Time", "Mass", "Volume", "Area",
|
136
|
+
"Force", "EnergyHeatWork", "PowerThermalDuty",
|
137
|
+
|
138
|
+
# Core classes for advanced usage
|
139
|
+
"FastQuantity", "TypeSafeVariable", "TypeSafeSetter",
|
140
|
+
"DimensionSignature", "BaseDimension",
|
141
|
+
"Expression", "Equation",
|
142
|
+
|
143
|
+
# All other variable types (95 additional types)
|
144
|
+
"AbsorbedDose", "Acceleration", "ActivationEnergy", "AmountOfSubstance",
|
145
|
+
"AnglePlane", "AngleSolid", "AngularAcceleration", "AngularMomentum",
|
146
|
+
"AreaPerUnitVolume", "AtomicWeight", "Concentration", "DynamicFluidity",
|
147
|
+
"ElectricCapacitance", "ElectricCharge", "ElectricCurrentIntensity",
|
148
|
+
"ElectricDipoleMoment", "ElectricFieldStrength", "ElectricInductance",
|
149
|
+
"ElectricPotential", "ElectricResistance", "ElectricalConductance",
|
150
|
+
"ElectricalPermittivity", "ElectricalResistivity", "EnergyFlux",
|
151
|
+
"EnergyPerUnitArea", "ForceBody", "ForcePerUnitMass",
|
152
|
+
"FrequencyVoltageRatio", "FuelConsumption", "HeatOfCombustion",
|
153
|
+
"HeatOfFusion", "HeatOfVaporization", "HeatTransferCoefficient",
|
154
|
+
"Illuminance", "KineticEnergyOfTurbulence", "LinearMassDensity",
|
155
|
+
"LinearMomentum", "LuminanceSelf", "LuminousFlux", "LuminousIntensity",
|
156
|
+
"MagneticField", "MagneticFlux", "MagneticInductionFieldStrength",
|
157
|
+
"MagneticMoment", "MagneticPermeability", "MagnetomotiveForce",
|
158
|
+
"MassDensity", "MassFlowRate", "MassFlux", "MassFractionOfI",
|
159
|
+
"MassTransferCoefficient", "MolalityOfSoluteI", "MolarConcentrationByMass",
|
160
|
+
"MolarFlowRate", "MolarFlux", "MolarHeatCapacity", "MolarityOfI",
|
161
|
+
"MoleFractionOfI", "MomentOfInertia", "MomentumFlowRate", "MomentumFlux",
|
162
|
+
"NormalityOfSolution", "ParticleDensity", "Permeability",
|
163
|
+
"PhotonEmissionRate", "PowerPerUnitMass", "PowerPerUnitVolume",
|
164
|
+
"RadiationDoseEquivalent", "RadiationExposure", "Radioactivity",
|
165
|
+
"SecondMomentOfArea", "SecondRadiationConstantPlanck", "SpecificEnthalpy",
|
166
|
+
"SpecificGravity", "SpecificHeatCapacityConstantPressure",
|
167
|
+
"SpecificLength", "SpecificSurface", "SpecificVolume", "Stress",
|
168
|
+
"SurfaceMassDensity", "SurfaceTension", "ThermalConductivity", "Torque",
|
169
|
+
"TurbulenceEnergyDissipationRate", "VelocityAngular", "VelocityLinear",
|
170
|
+
"ViscosityDynamic", "ViscosityKinematic", "VolumeFractionOfI",
|
171
|
+
"VolumetricCalorificHeatingValue", "VolumetricCoefficientOfExpansion",
|
172
|
+
"VolumetricFlowRate", "VolumetricFlux", "VolumetricMassFlowRate",
|
173
|
+
"Wavenumber",
|
174
|
+
]
|
175
|
+
|