qnty 0.0.8__tar.gz → 0.1.0__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.1.0/PKG-INFO +199 -0
- qnty-0.1.0/README.md +167 -0
- {qnty-0.0.8 → qnty-0.1.0}/pyproject.toml +1 -1
- qnty-0.1.0/src/qnty/__init__.py +255 -0
- qnty-0.1.0/src/qnty/constants/__init__.py +10 -0
- qnty-0.1.0/src/qnty/constants/numerical.py +18 -0
- qnty-0.1.0/src/qnty/constants/solvers.py +6 -0
- qnty-0.1.0/src/qnty/constants/tests.py +6 -0
- qnty-0.1.0/src/qnty/dimensions/__init__.py +23 -0
- qnty-0.1.0/src/qnty/dimensions/base.py +97 -0
- qnty-0.1.0/src/qnty/dimensions/field_dims.py +126 -0
- qnty-0.1.0/src/qnty/dimensions/field_dims.pyi +128 -0
- qnty-0.1.0/src/qnty/dimensions/signature.py +111 -0
- qnty-0.1.0/src/qnty/equations/__init__.py +4 -0
- qnty-0.1.0/src/qnty/equations/equation.py +220 -0
- qnty-0.1.0/src/qnty/equations/system.py +130 -0
- qnty-0.1.0/src/qnty/expressions/__init__.py +40 -0
- qnty-0.1.0/src/qnty/expressions/formatter.py +188 -0
- qnty-0.1.0/src/qnty/expressions/functions.py +74 -0
- qnty-0.1.0/src/qnty/expressions/nodes.py +701 -0
- qnty-0.1.0/src/qnty/expressions/types.py +70 -0
- qnty-0.1.0/src/qnty/extensions/plotting/__init__.py +0 -0
- qnty-0.1.0/src/qnty/extensions/reporting/__init__.py +0 -0
- qnty-0.1.0/src/qnty/problems/__init__.py +145 -0
- qnty-0.1.0/src/qnty/problems/composition.py +1031 -0
- qnty-0.1.0/src/qnty/problems/problem.py +695 -0
- qnty-0.1.0/src/qnty/problems/rules.py +145 -0
- qnty-0.1.0/src/qnty/problems/solving.py +1216 -0
- qnty-0.1.0/src/qnty/problems/validation.py +127 -0
- qnty-0.1.0/src/qnty/quantities/__init__.py +29 -0
- qnty-0.1.0/src/qnty/quantities/base_qnty.py +677 -0
- qnty-0.1.0/src/qnty/quantities/field_converters.py +24004 -0
- qnty-0.1.0/src/qnty/quantities/field_qnty.py +1012 -0
- qnty-0.1.0/src/qnty/quantities/field_setter.py +12320 -0
- qnty-0.1.0/src/qnty/quantities/field_vars.py +6325 -0
- qnty-0.1.0/src/qnty/quantities/field_vars.pyi +4191 -0
- qnty-0.1.0/src/qnty/solving/__init__.py +0 -0
- qnty-0.1.0/src/qnty/solving/manager.py +96 -0
- qnty-0.1.0/src/qnty/solving/order.py +403 -0
- qnty-0.1.0/src/qnty/solving/solvers/__init__.py +13 -0
- qnty-0.1.0/src/qnty/solving/solvers/base.py +82 -0
- qnty-0.1.0/src/qnty/solving/solvers/iterative.py +165 -0
- qnty-0.1.0/src/qnty/solving/solvers/simultaneous.py +475 -0
- qnty-0.1.0/src/qnty/units/__init__.py +1 -0
- qnty-0.1.0/src/qnty/units/field_units.py +10507 -0
- qnty-0.1.0/src/qnty/units/field_units.pyi +2461 -0
- qnty-0.1.0/src/qnty/units/prefixes.py +203 -0
- qnty-0.0.8/src/qnty/unit.py → qnty-0.1.0/src/qnty/units/registry.py +89 -61
- qnty-0.1.0/src/qnty/utils/__init__.py +16 -0
- qnty-0.1.0/src/qnty/utils/caching/__init__.py +23 -0
- qnty-0.1.0/src/qnty/utils/caching/manager.py +401 -0
- qnty-0.1.0/src/qnty/utils/error_handling/__init__.py +66 -0
- qnty-0.1.0/src/qnty/utils/error_handling/context.py +39 -0
- qnty-0.1.0/src/qnty/utils/error_handling/exceptions.py +96 -0
- qnty-0.1.0/src/qnty/utils/error_handling/handlers.py +171 -0
- qnty-0.1.0/src/qnty/utils/logging.py +40 -0
- qnty-0.1.0/src/qnty/utils/protocols.py +164 -0
- qnty-0.1.0/src/qnty/utils/scope_discovery.py +420 -0
- qnty-0.0.8/PKG-INFO +0 -355
- qnty-0.0.8/README.md +0 -323
- qnty-0.0.8/src/qnty/__init__.py +0 -174
- qnty-0.0.8/src/qnty/dimension.py +0 -186
- qnty-0.0.8/src/qnty/equation.py +0 -297
- qnty-0.0.8/src/qnty/expression.py +0 -553
- qnty-0.0.8/src/qnty/prefixes.py +0 -229
- qnty-0.0.8/src/qnty/unit_types/base.py +0 -47
- qnty-0.0.8/src/qnty/units.py +0 -8113
- qnty-0.0.8/src/qnty/variable.py +0 -300
- qnty-0.0.8/src/qnty/variable_types/base.py +0 -58
- qnty-0.0.8/src/qnty/variable_types/expression_variable.py +0 -106
- qnty-0.0.8/src/qnty/variable_types/typed_variable.py +0 -87
- qnty-0.0.8/src/qnty/variables.py +0 -2298
- qnty-0.0.8/src/qnty/variables.pyi +0 -6148
- {qnty-0.0.8/src/qnty/unit_types → qnty-0.1.0/src/qnty/extensions}/__init__.py +0 -0
- {qnty-0.0.8/src/qnty/variable_types → qnty-0.1.0/src/qnty/extensions/integration}/__init__.py +0 -0
qnty-0.1.0/PKG-INFO
ADDED
@@ -0,0 +1,199 @@
|
|
1
|
+
Metadata-Version: 2.3
|
2
|
+
Name: qnty
|
3
|
+
Version: 0.1.0
|
4
|
+
Summary: High-performance unit system library for Python with dimensional safety and fast unit conversions
|
5
|
+
License: Apache-2.0
|
6
|
+
Keywords: units,dimensional analysis,engineering,physics,quantities,measurements
|
7
|
+
Author: tn3wman
|
8
|
+
Requires-Python: >=3.11, <3.14
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
10
|
+
Classifier: Intended Audience :: Developers
|
11
|
+
Classifier: Intended Audience :: Science/Research
|
12
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
17
|
+
Classifier: Topic :: Scientific/Engineering
|
18
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
20
|
+
Provides-Extra: benchmark
|
21
|
+
Provides-Extra: dev
|
22
|
+
Requires-Dist: Pint (>=0.24.4) ; extra == "benchmark"
|
23
|
+
Requires-Dist: numpy (>=2.3.2)
|
24
|
+
Requires-Dist: pytest (>=8.4.1) ; extra == "dev"
|
25
|
+
Requires-Dist: ruff (>=0.1.0) ; extra == "dev"
|
26
|
+
Project-URL: Bug Tracker, https://github.com/tn3wman/qnty/issues
|
27
|
+
Project-URL: Documentation, https://github.com/tn3wman/qnty#readme
|
28
|
+
Project-URL: Homepage, https://github.com/tn3wman/qnty
|
29
|
+
Project-URL: Repository, https://github.com/tn3wman/qnty
|
30
|
+
Description-Content-Type: text/markdown
|
31
|
+
|
32
|
+
# Qnty
|
33
|
+
|
34
|
+
**High-performance unit system library for Python with dimensional safety and fast unit conversions for engineering calculations.**
|
35
|
+
|
36
|
+
[](https://www.python.org/downloads/)
|
37
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
38
|
+
[](https://pypi.org/project/qnty/)
|
39
|
+
|
40
|
+
## ⚠️ Important Disclaimer
|
41
|
+
|
42
|
+
**🚧 Work in Progress**: Qnty is currently in active development and has not been thoroughly vetted for production engineering calculations. While we strive for accuracy, this library should not be used for critical engineering applications without independent verification.
|
43
|
+
|
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
|
+
|
46
|
+
*Use Qnty to help prevent unit errors, but always verify critical calculations through multiple methods.*
|
47
|
+
|
48
|
+
---
|
49
|
+
|
50
|
+
## ✨ Key Features
|
51
|
+
|
52
|
+
- **🚀 Ultra-Fast Performance**: Prime number encoding and pre-computed conversion tables
|
53
|
+
- **🛡️ Type Safety**: Compile-time dimensional analysis prevents unit errors
|
54
|
+
- **⚡ Zero-Cost Abstractions**: Optimized operations with `__slots__` and caching
|
55
|
+
- **🔗 Fluent API**: Intuitive method chaining for readable code
|
56
|
+
- **🧮 Engineering-Focused**: Built for real-world engineering calculations
|
57
|
+
- **🧬 Mathematical System**: Built-in equation solving and expression trees
|
58
|
+
- **📊 Comprehensive Testing**: 187 tests with performance benchmarks
|
59
|
+
|
60
|
+
## 🚀 Quick Start
|
61
|
+
|
62
|
+
### Installation
|
63
|
+
|
64
|
+
```bash
|
65
|
+
pip install qnty
|
66
|
+
```
|
67
|
+
|
68
|
+
### Basic Usage
|
69
|
+
|
70
|
+
```python
|
71
|
+
from qnty import Length, Pressure, Area
|
72
|
+
|
73
|
+
# Create quantities with dimensional safety
|
74
|
+
width = Length(3, "meter", "Width")
|
75
|
+
height = Length(2, "meter", "Height")
|
76
|
+
|
77
|
+
# Solve mathematical expressions
|
78
|
+
area = Area("area", is_known=False)
|
79
|
+
area.solve_from(width * height)
|
80
|
+
print(f"Area: {area}") # Area: 6.0 m²
|
81
|
+
```
|
82
|
+
|
83
|
+
### Engineering Example
|
84
|
+
|
85
|
+
```python
|
86
|
+
from qnty import Problem, Length, Pressure
|
87
|
+
|
88
|
+
class PipeThickness(Problem):
|
89
|
+
"""Calculate pipe wall thickness"""
|
90
|
+
|
91
|
+
# Known parameters
|
92
|
+
pressure = Pressure(150, "pound_force_per_square_inch", "Internal Pressure")
|
93
|
+
diameter = Length(6, "inch", "Pipe Diameter")
|
94
|
+
allowable_stress = Pressure(20000, "pound_force_per_square_inch", "Allowable Stress")
|
95
|
+
|
96
|
+
# Unknown to solve for
|
97
|
+
thickness = Length("thickness", is_known=False)
|
98
|
+
|
99
|
+
# Engineering equation: t = (P × D) / (2 × S)
|
100
|
+
equation = thickness.equals((pressure * diameter) / (2 * allowable_stress))
|
101
|
+
|
102
|
+
# Solve the problem
|
103
|
+
problem = PipeThickness()
|
104
|
+
problem.solve()
|
105
|
+
print(f"Required thickness: {problem.thickness}")
|
106
|
+
```
|
107
|
+
|
108
|
+
### Mathematical Operations
|
109
|
+
|
110
|
+
```python
|
111
|
+
from qnty import Length, sqrt, Area
|
112
|
+
|
113
|
+
# Dimensional analysis with mathematical functions
|
114
|
+
area = Area(25, "square_meter", "Square Area")
|
115
|
+
side = Length("side", is_known=False)
|
116
|
+
side.solve_from(sqrt(area)) # Returns Length, not Area!
|
117
|
+
print(f"Side length: {side}") # Side length: 5.0 m
|
118
|
+
```
|
119
|
+
|
120
|
+
## 📚 Documentation
|
121
|
+
|
122
|
+
- **[📖 Tutorial](docs/TUTORIAL.md)** - Step-by-step learning guide
|
123
|
+
- **[📋 API Reference](docs/API_REFERENCE.md)** - Complete API documentation
|
124
|
+
- **[🏗️ Examples](examples/)** - Real-world engineering examples
|
125
|
+
- **[📁 Full Documentation](docs/)** - Complete documentation index
|
126
|
+
|
127
|
+
## 🚀 Performance
|
128
|
+
|
129
|
+
Qnty significantly outperforms other unit libraries with **18.9x average speedup** over Pint:
|
130
|
+
|
131
|
+
| Operation | Qnty | Pint | **Speedup** |
|
132
|
+
|-----------|------|------|-------------|
|
133
|
+
| Mixed Unit Addition | 0.76 μs | 17.52 μs | **23.1x** |
|
134
|
+
| Complex ASME Equation | 4.07 μs | 106.17 μs | **26.1x** 🚀 |
|
135
|
+
| Type-Safe Variables | 0.98 μs | 9.65 μs | **9.8x** |
|
136
|
+
| **AVERAGE** | **1.89 μs** | **35.83 μs** | **18.9x** 🏆 |
|
137
|
+
|
138
|
+
*Run `pytest tests/test_benchmark.py -v -s` to verify on your system.*
|
139
|
+
|
140
|
+
## 🧮 100+ Engineering Quantities
|
141
|
+
|
142
|
+
Qnty provides comprehensive coverage of engineering domains:
|
143
|
+
|
144
|
+
```python
|
145
|
+
from qnty import (
|
146
|
+
# Mechanical
|
147
|
+
Length, Area, Volume, Mass, Force, Pressure, Temperature,
|
148
|
+
# Electrical
|
149
|
+
ElectricPotential, ElectricCurrentIntensity, ElectricResistance,
|
150
|
+
# Thermal
|
151
|
+
ThermalConductivity, HeatTransferCoefficient,
|
152
|
+
# Fluid Dynamics
|
153
|
+
ViscosityDynamic, MassFlowRate, VolumetricFlowRate,
|
154
|
+
# And 80+ more...
|
155
|
+
)
|
156
|
+
```
|
157
|
+
|
158
|
+
## 🔧 Development
|
159
|
+
|
160
|
+
```bash
|
161
|
+
# Install dependencies
|
162
|
+
pip install -r requirements.txt
|
163
|
+
|
164
|
+
# Run tests
|
165
|
+
pytest
|
166
|
+
|
167
|
+
# Run specific test
|
168
|
+
pytest tests/test_dimension.py -v
|
169
|
+
|
170
|
+
# Run benchmarks
|
171
|
+
python tests/test_benchmark.py
|
172
|
+
|
173
|
+
# Lint code
|
174
|
+
ruff check src/ tests/
|
175
|
+
ruff format src/ tests/
|
176
|
+
```
|
177
|
+
|
178
|
+
## 📄 License
|
179
|
+
|
180
|
+
This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.
|
181
|
+
|
182
|
+
## 🤝 Contributing
|
183
|
+
|
184
|
+
We welcome contributions! Please see [CLAUDE.md](CLAUDE.md) for development guidelines and:
|
185
|
+
|
186
|
+
1. Fork the repository
|
187
|
+
2. Create a feature branch
|
188
|
+
3. Add tests for new functionality
|
189
|
+
4. Ensure all tests pass: `pytest`
|
190
|
+
5. Submit a pull request
|
191
|
+
|
192
|
+
---
|
193
|
+
|
194
|
+
**Ready to supercharge your engineering calculations?** 🚀
|
195
|
+
|
196
|
+
- Start with the **[Tutorial](docs/TUTORIAL.md)**
|
197
|
+
- Browse the **[API Reference](docs/API_REFERENCE.md)**
|
198
|
+
- Try the **[Examples](examples/)**
|
199
|
+
|
qnty-0.1.0/README.md
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
# Qnty
|
2
|
+
|
3
|
+
**High-performance unit system library for Python with dimensional safety and fast unit conversions for engineering calculations.**
|
4
|
+
|
5
|
+
[](https://www.python.org/downloads/)
|
6
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
7
|
+
[](https://pypi.org/project/qnty/)
|
8
|
+
|
9
|
+
## ⚠️ Important Disclaimer
|
10
|
+
|
11
|
+
**🚧 Work in Progress**: Qnty is currently in active development and has not been thoroughly vetted for production engineering calculations. While we strive for accuracy, this library should not be used for critical engineering applications without independent verification.
|
12
|
+
|
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
|
+
|
15
|
+
*Use Qnty to help prevent unit errors, but always verify critical calculations through multiple methods.*
|
16
|
+
|
17
|
+
---
|
18
|
+
|
19
|
+
## ✨ Key Features
|
20
|
+
|
21
|
+
- **🚀 Ultra-Fast Performance**: Prime number encoding and pre-computed conversion tables
|
22
|
+
- **🛡️ Type Safety**: Compile-time dimensional analysis prevents unit errors
|
23
|
+
- **⚡ Zero-Cost Abstractions**: Optimized operations with `__slots__` and caching
|
24
|
+
- **🔗 Fluent API**: Intuitive method chaining for readable code
|
25
|
+
- **🧮 Engineering-Focused**: Built for real-world engineering calculations
|
26
|
+
- **🧬 Mathematical System**: Built-in equation solving and expression trees
|
27
|
+
- **📊 Comprehensive Testing**: 187 tests with performance benchmarks
|
28
|
+
|
29
|
+
## 🚀 Quick Start
|
30
|
+
|
31
|
+
### Installation
|
32
|
+
|
33
|
+
```bash
|
34
|
+
pip install qnty
|
35
|
+
```
|
36
|
+
|
37
|
+
### Basic Usage
|
38
|
+
|
39
|
+
```python
|
40
|
+
from qnty import Length, Pressure, Area
|
41
|
+
|
42
|
+
# Create quantities with dimensional safety
|
43
|
+
width = Length(3, "meter", "Width")
|
44
|
+
height = Length(2, "meter", "Height")
|
45
|
+
|
46
|
+
# Solve mathematical expressions
|
47
|
+
area = Area("area", is_known=False)
|
48
|
+
area.solve_from(width * height)
|
49
|
+
print(f"Area: {area}") # Area: 6.0 m²
|
50
|
+
```
|
51
|
+
|
52
|
+
### Engineering Example
|
53
|
+
|
54
|
+
```python
|
55
|
+
from qnty import Problem, Length, Pressure
|
56
|
+
|
57
|
+
class PipeThickness(Problem):
|
58
|
+
"""Calculate pipe wall thickness"""
|
59
|
+
|
60
|
+
# Known parameters
|
61
|
+
pressure = Pressure(150, "pound_force_per_square_inch", "Internal Pressure")
|
62
|
+
diameter = Length(6, "inch", "Pipe Diameter")
|
63
|
+
allowable_stress = Pressure(20000, "pound_force_per_square_inch", "Allowable Stress")
|
64
|
+
|
65
|
+
# Unknown to solve for
|
66
|
+
thickness = Length("thickness", is_known=False)
|
67
|
+
|
68
|
+
# Engineering equation: t = (P × D) / (2 × S)
|
69
|
+
equation = thickness.equals((pressure * diameter) / (2 * allowable_stress))
|
70
|
+
|
71
|
+
# Solve the problem
|
72
|
+
problem = PipeThickness()
|
73
|
+
problem.solve()
|
74
|
+
print(f"Required thickness: {problem.thickness}")
|
75
|
+
```
|
76
|
+
|
77
|
+
### Mathematical Operations
|
78
|
+
|
79
|
+
```python
|
80
|
+
from qnty import Length, sqrt, Area
|
81
|
+
|
82
|
+
# Dimensional analysis with mathematical functions
|
83
|
+
area = Area(25, "square_meter", "Square Area")
|
84
|
+
side = Length("side", is_known=False)
|
85
|
+
side.solve_from(sqrt(area)) # Returns Length, not Area!
|
86
|
+
print(f"Side length: {side}") # Side length: 5.0 m
|
87
|
+
```
|
88
|
+
|
89
|
+
## 📚 Documentation
|
90
|
+
|
91
|
+
- **[📖 Tutorial](docs/TUTORIAL.md)** - Step-by-step learning guide
|
92
|
+
- **[📋 API Reference](docs/API_REFERENCE.md)** - Complete API documentation
|
93
|
+
- **[🏗️ Examples](examples/)** - Real-world engineering examples
|
94
|
+
- **[📁 Full Documentation](docs/)** - Complete documentation index
|
95
|
+
|
96
|
+
## 🚀 Performance
|
97
|
+
|
98
|
+
Qnty significantly outperforms other unit libraries with **18.9x average speedup** over Pint:
|
99
|
+
|
100
|
+
| Operation | Qnty | Pint | **Speedup** |
|
101
|
+
|-----------|------|------|-------------|
|
102
|
+
| Mixed Unit Addition | 0.76 μs | 17.52 μs | **23.1x** |
|
103
|
+
| Complex ASME Equation | 4.07 μs | 106.17 μs | **26.1x** 🚀 |
|
104
|
+
| Type-Safe Variables | 0.98 μs | 9.65 μs | **9.8x** |
|
105
|
+
| **AVERAGE** | **1.89 μs** | **35.83 μs** | **18.9x** 🏆 |
|
106
|
+
|
107
|
+
*Run `pytest tests/test_benchmark.py -v -s` to verify on your system.*
|
108
|
+
|
109
|
+
## 🧮 100+ Engineering Quantities
|
110
|
+
|
111
|
+
Qnty provides comprehensive coverage of engineering domains:
|
112
|
+
|
113
|
+
```python
|
114
|
+
from qnty import (
|
115
|
+
# Mechanical
|
116
|
+
Length, Area, Volume, Mass, Force, Pressure, Temperature,
|
117
|
+
# Electrical
|
118
|
+
ElectricPotential, ElectricCurrentIntensity, ElectricResistance,
|
119
|
+
# Thermal
|
120
|
+
ThermalConductivity, HeatTransferCoefficient,
|
121
|
+
# Fluid Dynamics
|
122
|
+
ViscosityDynamic, MassFlowRate, VolumetricFlowRate,
|
123
|
+
# And 80+ more...
|
124
|
+
)
|
125
|
+
```
|
126
|
+
|
127
|
+
## 🔧 Development
|
128
|
+
|
129
|
+
```bash
|
130
|
+
# Install dependencies
|
131
|
+
pip install -r requirements.txt
|
132
|
+
|
133
|
+
# Run tests
|
134
|
+
pytest
|
135
|
+
|
136
|
+
# Run specific test
|
137
|
+
pytest tests/test_dimension.py -v
|
138
|
+
|
139
|
+
# Run benchmarks
|
140
|
+
python tests/test_benchmark.py
|
141
|
+
|
142
|
+
# Lint code
|
143
|
+
ruff check src/ tests/
|
144
|
+
ruff format src/ tests/
|
145
|
+
```
|
146
|
+
|
147
|
+
## 📄 License
|
148
|
+
|
149
|
+
This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.
|
150
|
+
|
151
|
+
## 🤝 Contributing
|
152
|
+
|
153
|
+
We welcome contributions! Please see [CLAUDE.md](CLAUDE.md) for development guidelines and:
|
154
|
+
|
155
|
+
1. Fork the repository
|
156
|
+
2. Create a feature branch
|
157
|
+
3. Add tests for new functionality
|
158
|
+
4. Ensure all tests pass: `pytest`
|
159
|
+
5. Submit a pull request
|
160
|
+
|
161
|
+
---
|
162
|
+
|
163
|
+
**Ready to supercharge your engineering calculations?** 🚀
|
164
|
+
|
165
|
+
- Start with the **[Tutorial](docs/TUTORIAL.md)**
|
166
|
+
- Browse the **[API Reference](docs/API_REFERENCE.md)**
|
167
|
+
- Try the **[Examples](examples/)**
|
@@ -0,0 +1,255 @@
|
|
1
|
+
"""
|
2
|
+
Qnty - High-Performance Unit System for Engineering
|
3
|
+
====================================================
|
4
|
+
|
5
|
+
A fast, type-safe unit system library for Python with dimensional safety and optimized unit conversions for engineering calculations.
|
6
|
+
"""
|
7
|
+
|
8
|
+
# from . import (quantity, expressions)
|
9
|
+
|
10
|
+
from .expressions import (
|
11
|
+
abs_expr,
|
12
|
+
cond_expr,
|
13
|
+
cos,
|
14
|
+
exp,
|
15
|
+
ln,
|
16
|
+
log10,
|
17
|
+
max_expr,
|
18
|
+
min_expr,
|
19
|
+
sin,
|
20
|
+
sqrt,
|
21
|
+
tan,
|
22
|
+
)
|
23
|
+
from .problems import Problem
|
24
|
+
from .quantities.field_vars import (
|
25
|
+
AbsorbedDose,
|
26
|
+
Acceleration,
|
27
|
+
ActivationEnergy,
|
28
|
+
AmountOfSubstance,
|
29
|
+
AnglePlane,
|
30
|
+
AngleSolid,
|
31
|
+
AngularAcceleration,
|
32
|
+
AngularMomentum,
|
33
|
+
Area,
|
34
|
+
AreaPerUnitVolume,
|
35
|
+
AtomicWeight,
|
36
|
+
Concentration,
|
37
|
+
Dimensionless,
|
38
|
+
DynamicFluidity,
|
39
|
+
ElectricalConductance,
|
40
|
+
ElectricalPermittivity,
|
41
|
+
ElectricalResistivity,
|
42
|
+
ElectricCapacitance,
|
43
|
+
ElectricCharge,
|
44
|
+
ElectricCurrentIntensity,
|
45
|
+
ElectricDipoleMoment,
|
46
|
+
ElectricFieldStrength,
|
47
|
+
ElectricInductance,
|
48
|
+
ElectricPotential,
|
49
|
+
ElectricResistance,
|
50
|
+
EnergyFlux,
|
51
|
+
EnergyHeatWork,
|
52
|
+
EnergyPerUnitArea,
|
53
|
+
Force,
|
54
|
+
ForceBody,
|
55
|
+
ForcePerUnitMass,
|
56
|
+
FrequencyVoltageRatio,
|
57
|
+
FuelConsumption,
|
58
|
+
HeatOfCombustion,
|
59
|
+
HeatOfFusion,
|
60
|
+
HeatOfVaporization,
|
61
|
+
HeatTransferCoefficient,
|
62
|
+
Illuminance,
|
63
|
+
KineticEnergyOfTurbulence,
|
64
|
+
Length,
|
65
|
+
LinearMassDensity,
|
66
|
+
LinearMomentum,
|
67
|
+
LuminanceSelf,
|
68
|
+
LuminousFlux,
|
69
|
+
LuminousIntensity,
|
70
|
+
MagneticField,
|
71
|
+
MagneticFlux,
|
72
|
+
MagneticInductionFieldStrength,
|
73
|
+
MagneticMoment,
|
74
|
+
MagneticPermeability,
|
75
|
+
MagnetomotiveForce,
|
76
|
+
Mass,
|
77
|
+
MassDensity,
|
78
|
+
MassFlowRate,
|
79
|
+
MassFlux,
|
80
|
+
MassFractionOfI,
|
81
|
+
MassTransferCoefficient,
|
82
|
+
MolalityOfSoluteI,
|
83
|
+
MolarConcentrationByMass,
|
84
|
+
MolarFlowRate,
|
85
|
+
MolarFlux,
|
86
|
+
MolarHeatCapacity,
|
87
|
+
MolarityOfI,
|
88
|
+
MoleFractionOfI,
|
89
|
+
MomentOfInertia,
|
90
|
+
MomentumFlowRate,
|
91
|
+
MomentumFlux,
|
92
|
+
NormalityOfSolution,
|
93
|
+
ParticleDensity,
|
94
|
+
Percent,
|
95
|
+
Permeability,
|
96
|
+
PhotonEmissionRate,
|
97
|
+
PowerPerUnitMass,
|
98
|
+
PowerPerUnitVolume,
|
99
|
+
PowerThermalDuty,
|
100
|
+
Pressure,
|
101
|
+
RadiationDoseEquivalent,
|
102
|
+
RadiationExposure,
|
103
|
+
Radioactivity,
|
104
|
+
SecondMomentOfArea,
|
105
|
+
SecondRadiationConstantPlanck,
|
106
|
+
SpecificEnthalpy,
|
107
|
+
SpecificGravity,
|
108
|
+
SpecificHeatCapacityConstantPressure,
|
109
|
+
SpecificLength,
|
110
|
+
SpecificSurface,
|
111
|
+
SpecificVolume,
|
112
|
+
Stress,
|
113
|
+
SurfaceMassDensity,
|
114
|
+
SurfaceTension,
|
115
|
+
Temperature,
|
116
|
+
ThermalConductivity,
|
117
|
+
Time,
|
118
|
+
Torque,
|
119
|
+
TurbulenceEnergyDissipationRate,
|
120
|
+
VelocityAngular,
|
121
|
+
VelocityLinear,
|
122
|
+
ViscosityDynamic,
|
123
|
+
ViscosityKinematic,
|
124
|
+
Volume,
|
125
|
+
VolumeFractionOfI,
|
126
|
+
VolumetricCalorificHeatingValue,
|
127
|
+
VolumetricCoefficientOfExpansion,
|
128
|
+
VolumetricFlowRate,
|
129
|
+
VolumetricFlux,
|
130
|
+
VolumetricMassFlowRate,
|
131
|
+
Wavenumber,
|
132
|
+
)
|
133
|
+
|
134
|
+
# Define public API
|
135
|
+
__all__ = [
|
136
|
+
"abs_expr",
|
137
|
+
"min_expr",
|
138
|
+
"max_expr",
|
139
|
+
"cond_expr",
|
140
|
+
"sin",
|
141
|
+
"cos",
|
142
|
+
"tan",
|
143
|
+
"sqrt",
|
144
|
+
"ln",
|
145
|
+
"log10",
|
146
|
+
"exp",
|
147
|
+
"Problem",
|
148
|
+
"AbsorbedDose",
|
149
|
+
"Acceleration",
|
150
|
+
"ActivationEnergy",
|
151
|
+
"AmountOfSubstance",
|
152
|
+
"AnglePlane",
|
153
|
+
"AngleSolid",
|
154
|
+
"AngularAcceleration",
|
155
|
+
"AngularMomentum",
|
156
|
+
"Area",
|
157
|
+
"AreaPerUnitVolume",
|
158
|
+
"AtomicWeight",
|
159
|
+
"Concentration",
|
160
|
+
"Dimensionless",
|
161
|
+
"DynamicFluidity",
|
162
|
+
"ElectricalConductance",
|
163
|
+
"ElectricalPermittivity",
|
164
|
+
"ElectricalResistivity",
|
165
|
+
"ElectricCapacitance",
|
166
|
+
"ElectricCharge",
|
167
|
+
"ElectricCurrentIntensity",
|
168
|
+
"ElectricDipoleMoment",
|
169
|
+
"ElectricFieldStrength",
|
170
|
+
"ElectricInductance",
|
171
|
+
"ElectricPotential",
|
172
|
+
"ElectricResistance",
|
173
|
+
"EnergyFlux",
|
174
|
+
"EnergyHeatWork",
|
175
|
+
"EnergyPerUnitArea",
|
176
|
+
"Force",
|
177
|
+
"ForceBody",
|
178
|
+
"ForcePerUnitMass",
|
179
|
+
"FrequencyVoltageRatio",
|
180
|
+
"FuelConsumption",
|
181
|
+
"HeatOfCombustion",
|
182
|
+
"HeatOfFusion",
|
183
|
+
"HeatOfVaporization",
|
184
|
+
"HeatTransferCoefficient",
|
185
|
+
"Illuminance",
|
186
|
+
"KineticEnergyOfTurbulence",
|
187
|
+
"Length",
|
188
|
+
"LinearMassDensity",
|
189
|
+
"LinearMomentum",
|
190
|
+
"LuminanceSelf",
|
191
|
+
"LuminousFlux",
|
192
|
+
"LuminousIntensity",
|
193
|
+
"MagneticField",
|
194
|
+
"MagneticFlux",
|
195
|
+
"MagneticInductionFieldStrength",
|
196
|
+
"MagneticMoment",
|
197
|
+
"MagneticPermeability",
|
198
|
+
"MagnetomotiveForce",
|
199
|
+
"Mass",
|
200
|
+
"MassDensity",
|
201
|
+
"MassFlowRate",
|
202
|
+
"MassFlux",
|
203
|
+
"MassFractionOfI",
|
204
|
+
"MassTransferCoefficient",
|
205
|
+
"MolalityOfSoluteI",
|
206
|
+
"MolarConcentrationByMass",
|
207
|
+
"MolarFlowRate",
|
208
|
+
"MolarFlux",
|
209
|
+
"MolarHeatCapacity",
|
210
|
+
"MolarityOfI",
|
211
|
+
"MoleFractionOfI",
|
212
|
+
"MomentOfInertia",
|
213
|
+
"MomentumFlowRate",
|
214
|
+
"MomentumFlux",
|
215
|
+
"NormalityOfSolution",
|
216
|
+
"ParticleDensity",
|
217
|
+
"Percent",
|
218
|
+
"Permeability",
|
219
|
+
"PhotonEmissionRate",
|
220
|
+
"PowerPerUnitMass",
|
221
|
+
"PowerPerUnitVolume",
|
222
|
+
"PowerThermalDuty",
|
223
|
+
"Pressure",
|
224
|
+
"RadiationDoseEquivalent",
|
225
|
+
"RadiationExposure",
|
226
|
+
"Radioactivity",
|
227
|
+
"SecondMomentOfArea",
|
228
|
+
"SecondRadiationConstantPlanck",
|
229
|
+
"SpecificEnthalpy",
|
230
|
+
"SpecificGravity",
|
231
|
+
"SpecificHeatCapacityConstantPressure",
|
232
|
+
"SpecificLength",
|
233
|
+
"SpecificSurface",
|
234
|
+
"SpecificVolume",
|
235
|
+
"Stress",
|
236
|
+
"SurfaceMassDensity",
|
237
|
+
"SurfaceTension",
|
238
|
+
"Temperature",
|
239
|
+
"ThermalConductivity",
|
240
|
+
"Time",
|
241
|
+
"Torque",
|
242
|
+
"TurbulenceEnergyDissipationRate",
|
243
|
+
"VelocityAngular",
|
244
|
+
"VelocityLinear",
|
245
|
+
"ViscosityDynamic",
|
246
|
+
"ViscosityKinematic",
|
247
|
+
"Volume",
|
248
|
+
"VolumeFractionOfI",
|
249
|
+
"VolumetricCalorificHeatingValue",
|
250
|
+
"VolumetricCoefficientOfExpansion",
|
251
|
+
"VolumetricFlowRate",
|
252
|
+
"VolumetricFlux",
|
253
|
+
"VolumetricMassFlowRate",
|
254
|
+
"Wavenumber",
|
255
|
+
]
|
@@ -0,0 +1,10 @@
|
|
1
|
+
"""
|
2
|
+
Mathematical and numerical constants used throughout the qnty library.
|
3
|
+
|
4
|
+
This module centralizes magic numbers and tolerances to improve maintainability
|
5
|
+
and consistency across the codebase.
|
6
|
+
"""
|
7
|
+
|
8
|
+
from .numerical import *
|
9
|
+
from .solvers import *
|
10
|
+
from .tests import *
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Numerical tolerances for floating point comparisons
|
2
|
+
FLOAT_EQUALITY_TOLERANCE = 1e-10
|
3
|
+
"""Default tolerance for floating point equality comparisons."""
|
4
|
+
|
5
|
+
DIVISION_BY_ZERO_THRESHOLD = 1e-15
|
6
|
+
"""Threshold below which a value is considered effectively zero for division."""
|
7
|
+
|
8
|
+
CONDITION_EVALUATION_THRESHOLD = 1e-10
|
9
|
+
"""Threshold for evaluating conditional expressions as true/false."""
|
10
|
+
|
11
|
+
DIMENSIONAL_PRECISION_TOLERANCE = 1e-10
|
12
|
+
"""Tolerance for dimensional signature comparisons."""
|
13
|
+
|
14
|
+
PREFIX_LOOKUP_TOLERANCE = 1e-10
|
15
|
+
"""Default tolerance for SI prefix factor lookup."""
|
16
|
+
|
17
|
+
PREFIX_LOOKUP_MIN_TOLERANCE = 1e-15
|
18
|
+
"""Minimum tolerance for SI prefix factor lookup to avoid expensive searches."""
|
@@ -0,0 +1,23 @@
|
|
1
|
+
"""
|
2
|
+
Core Dimensions Module
|
3
|
+
======================
|
4
|
+
|
5
|
+
Core dimensional analysis components providing compile-time type safety.
|
6
|
+
|
7
|
+
This module provides the fundamental building blocks for qnty's dimensional analysis system:
|
8
|
+
- BaseDimension: Prime-number-encoded base dimensions
|
9
|
+
- DimensionSignature: Ultra-fast dimensional compatibility checking
|
10
|
+
"""
|
11
|
+
|
12
|
+
from .base import BASE_DIMENSIONS, DIMENSION_SYMBOLS, PRIME_MAP, BaseDimension, DimensionConfig
|
13
|
+
from .field_dims import * # noqa: F403
|
14
|
+
from .signature import DimensionSignature
|
15
|
+
|
16
|
+
__all__ = (
|
17
|
+
"BaseDimension",
|
18
|
+
"DimensionSignature",
|
19
|
+
"DimensionConfig",
|
20
|
+
"BASE_DIMENSIONS",
|
21
|
+
"DIMENSION_SYMBOLS",
|
22
|
+
"PRIME_MAP"
|
23
|
+
)
|