qnty 0.0.8__py3-none-any.whl → 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. qnty/__init__.py +140 -59
  2. qnty/constants/__init__.py +10 -0
  3. qnty/constants/numerical.py +18 -0
  4. qnty/constants/solvers.py +6 -0
  5. qnty/constants/tests.py +6 -0
  6. qnty/dimensions/__init__.py +23 -0
  7. qnty/dimensions/base.py +97 -0
  8. qnty/dimensions/field_dims.py +126 -0
  9. qnty/dimensions/field_dims.pyi +128 -0
  10. qnty/dimensions/signature.py +111 -0
  11. qnty/equations/__init__.py +4 -0
  12. qnty/equations/equation.py +220 -0
  13. qnty/equations/system.py +130 -0
  14. qnty/expressions/__init__.py +40 -0
  15. qnty/expressions/formatter.py +188 -0
  16. qnty/expressions/functions.py +74 -0
  17. qnty/expressions/nodes.py +701 -0
  18. qnty/expressions/types.py +70 -0
  19. qnty/extensions/plotting/__init__.py +0 -0
  20. qnty/extensions/reporting/__init__.py +0 -0
  21. qnty/problems/__init__.py +145 -0
  22. qnty/problems/composition.py +1031 -0
  23. qnty/problems/problem.py +695 -0
  24. qnty/problems/rules.py +145 -0
  25. qnty/problems/solving.py +1216 -0
  26. qnty/problems/validation.py +127 -0
  27. qnty/quantities/__init__.py +29 -0
  28. qnty/quantities/base_qnty.py +677 -0
  29. qnty/quantities/field_converters.py +24004 -0
  30. qnty/quantities/field_qnty.py +1012 -0
  31. qnty/quantities/field_setter.py +12320 -0
  32. qnty/quantities/field_vars.py +6325 -0
  33. qnty/quantities/field_vars.pyi +4191 -0
  34. qnty/solving/__init__.py +0 -0
  35. qnty/solving/manager.py +96 -0
  36. qnty/solving/order.py +403 -0
  37. qnty/solving/solvers/__init__.py +13 -0
  38. qnty/solving/solvers/base.py +82 -0
  39. qnty/solving/solvers/iterative.py +165 -0
  40. qnty/solving/solvers/simultaneous.py +475 -0
  41. qnty/units/__init__.py +1 -0
  42. qnty/units/field_units.py +10507 -0
  43. qnty/units/field_units.pyi +2461 -0
  44. qnty/units/prefixes.py +203 -0
  45. qnty/{unit.py → units/registry.py} +89 -61
  46. qnty/utils/__init__.py +16 -0
  47. qnty/utils/caching/__init__.py +23 -0
  48. qnty/utils/caching/manager.py +401 -0
  49. qnty/utils/error_handling/__init__.py +66 -0
  50. qnty/utils/error_handling/context.py +39 -0
  51. qnty/utils/error_handling/exceptions.py +96 -0
  52. qnty/utils/error_handling/handlers.py +171 -0
  53. qnty/utils/logging.py +40 -0
  54. qnty/utils/protocols.py +164 -0
  55. qnty/utils/scope_discovery.py +420 -0
  56. qnty-0.1.0.dist-info/METADATA +199 -0
  57. qnty-0.1.0.dist-info/RECORD +60 -0
  58. qnty/dimension.py +0 -186
  59. qnty/equation.py +0 -297
  60. qnty/expression.py +0 -553
  61. qnty/prefixes.py +0 -229
  62. qnty/unit_types/base.py +0 -47
  63. qnty/units.py +0 -8113
  64. qnty/variable.py +0 -300
  65. qnty/variable_types/base.py +0 -58
  66. qnty/variable_types/expression_variable.py +0 -106
  67. qnty/variable_types/typed_variable.py +0 -87
  68. qnty/variables.py +0 -2298
  69. qnty/variables.pyi +0 -6148
  70. qnty-0.0.8.dist-info/METADATA +0 -355
  71. qnty-0.0.8.dist-info/RECORD +0 -19
  72. /qnty/{unit_types → extensions}/__init__.py +0 -0
  73. /qnty/{variable_types → extensions/integration}/__init__.py +0 -0
  74. {qnty-0.0.8.dist-info → qnty-0.1.0.dist-info}/WHEEL +0 -0
qnty/prefixes.py DELETED
@@ -1,229 +0,0 @@
1
- """
2
- SI Prefix System
3
- ================
4
-
5
- Standard SI prefixes for unit multiplication/division.
6
- Provides systematic handling of metric prefixes like kilo-, milli-, micro-, etc.
7
- """
8
-
9
- from dataclasses import dataclass
10
- from enum import Enum
11
-
12
-
13
- @dataclass(frozen=True)
14
- class SIPrefix:
15
- """
16
- Standard SI prefix definition.
17
-
18
- Attributes:
19
- name: Full prefix name (e.g., "kilo", "milli")
20
- symbol: Standard symbol (e.g., "k", "m")
21
- factor: Multiplication factor relative to base unit (e.g., 1000, 0.001)
22
- """
23
- name: str
24
- symbol: str
25
- factor: float
26
-
27
- def apply_to_name(self, base_name: str) -> str:
28
- """Apply prefix to a base unit name."""
29
- if not self.name:
30
- return base_name
31
- return f"{self.name}{base_name}"
32
-
33
- def apply_to_symbol(self, base_symbol: str) -> str:
34
- """Apply prefix to a base unit symbol."""
35
- if not self.symbol:
36
- return base_symbol
37
- return f"{self.symbol}{base_symbol}"
38
-
39
-
40
- class StandardPrefixes(Enum):
41
- """
42
- Standard SI prefixes with their multiplication factors.
43
-
44
- From yotta (10^24) to yocto (10^-24).
45
- """
46
- # Larger prefixes (10^3 to 10^24)
47
- YOTTA = SIPrefix("yotta", "Y", 1e24)
48
- ZETTA = SIPrefix("zetta", "Z", 1e21)
49
- EXA = SIPrefix("exa", "E", 1e18)
50
- PETA = SIPrefix("peta", "P", 1e15)
51
- TERA = SIPrefix("tera", "T", 1e12)
52
- GIGA = SIPrefix("giga", "G", 1e9)
53
- MEGA = SIPrefix("mega", "M", 1e6)
54
- KILO = SIPrefix("kilo", "k", 1e3)
55
- HECTO = SIPrefix("hecto", "h", 1e2)
56
- DECA = SIPrefix("deca", "da", 1e1)
57
-
58
- # Base (no prefix)
59
- NONE = SIPrefix("", "", 1.0)
60
-
61
- # Smaller prefixes (10^-1 to 10^-24)
62
- DECI = SIPrefix("deci", "d", 1e-1)
63
- CENTI = SIPrefix("centi", "c", 1e-2)
64
- MILLI = SIPrefix("milli", "m", 1e-3)
65
- MICRO = SIPrefix("micro", "μ", 1e-6)
66
- NANO = SIPrefix("nano", "n", 1e-9)
67
- PICO = SIPrefix("pico", "p", 1e-12)
68
- FEMTO = SIPrefix("femto", "f", 1e-15)
69
- ATTO = SIPrefix("atto", "a", 1e-18)
70
- ZEPTO = SIPrefix("zepto", "z", 1e-21)
71
- YOCTO = SIPrefix("yocto", "y", 1e-24)
72
-
73
-
74
- # Common prefix groups for different unit types
75
- COMMON_LENGTH_PREFIXES = [
76
- StandardPrefixes.KILO,
77
- StandardPrefixes.CENTI,
78
- StandardPrefixes.MILLI,
79
- StandardPrefixes.MICRO,
80
- StandardPrefixes.NANO,
81
- ]
82
-
83
- COMMON_MASS_PREFIXES = [
84
- StandardPrefixes.KILO, # Note: kilogram is the SI base unit
85
- StandardPrefixes.MILLI,
86
- StandardPrefixes.MICRO,
87
- ]
88
-
89
- COMMON_TIME_PREFIXES = [
90
- StandardPrefixes.MILLI,
91
- StandardPrefixes.MICRO,
92
- StandardPrefixes.NANO,
93
- StandardPrefixes.PICO,
94
- ]
95
-
96
- COMMON_ELECTRIC_PREFIXES = [
97
- StandardPrefixes.KILO,
98
- StandardPrefixes.MILLI,
99
- StandardPrefixes.MICRO,
100
- StandardPrefixes.NANO,
101
- StandardPrefixes.PICO,
102
- ]
103
-
104
- COMMON_ENERGY_PREFIXES = [
105
- StandardPrefixes.KILO,
106
- StandardPrefixes.MEGA,
107
- StandardPrefixes.GIGA,
108
- ]
109
-
110
- COMMON_POWER_PREFIXES = [
111
- StandardPrefixes.KILO,
112
- StandardPrefixes.MEGA,
113
- StandardPrefixes.GIGA,
114
- StandardPrefixes.MILLI,
115
- StandardPrefixes.MICRO,
116
- ]
117
-
118
- COMMON_PRESSURE_PREFIXES = [
119
- StandardPrefixes.KILO,
120
- StandardPrefixes.MEGA,
121
- StandardPrefixes.GIGA,
122
- ]
123
-
124
-
125
- def get_prefix_by_name(name: str) -> SIPrefix | None:
126
- """Get a prefix by its name (e.g., 'kilo', 'milli')."""
127
- for prefix_enum in StandardPrefixes:
128
- if prefix_enum.value.name == name:
129
- return prefix_enum.value
130
- return None
131
-
132
-
133
- def get_prefix_by_symbol(symbol: str) -> SIPrefix | None:
134
- """Get a prefix by its symbol (e.g., 'k', 'm')."""
135
- for prefix_enum in StandardPrefixes:
136
- if prefix_enum.value.symbol == symbol:
137
- return prefix_enum.value
138
- return None
139
-
140
-
141
- def get_prefix_by_factor(factor: float, tolerance: float = 1e-10) -> SIPrefix | None:
142
- """Get a prefix by its multiplication factor."""
143
- for prefix_enum in StandardPrefixes:
144
- if abs(prefix_enum.value.factor - factor) < tolerance:
145
- return prefix_enum.value
146
- return None
147
-
148
-
149
- # Define which units should get automatic prefixes
150
- PREFIXABLE_UNITS = {
151
- # Base SI units
152
- 'meter': COMMON_LENGTH_PREFIXES,
153
- 'gram': COMMON_MASS_PREFIXES,
154
- 'second': COMMON_TIME_PREFIXES,
155
- 'ampere': COMMON_ELECTRIC_PREFIXES,
156
- 'kelvin': [], # Temperature usually doesn't use prefixes
157
- 'mole': [
158
- StandardPrefixes.MILLI,
159
- StandardPrefixes.MICRO
160
- ],
161
- 'candela': [], # Luminous intensity rarely uses prefixes
162
-
163
- # Derived SI units
164
- 'pascal': COMMON_PRESSURE_PREFIXES,
165
- 'joule': COMMON_ENERGY_PREFIXES,
166
- 'watt': COMMON_POWER_PREFIXES,
167
- 'coulomb': COMMON_ELECTRIC_PREFIXES,
168
- 'volt': COMMON_ELECTRIC_PREFIXES,
169
- 'farad': [
170
- StandardPrefixes.MILLI,
171
- StandardPrefixes.MICRO,
172
- StandardPrefixes.NANO,
173
- StandardPrefixes.PICO
174
- ],
175
- 'ohm': [
176
- StandardPrefixes.KILO,
177
- StandardPrefixes.MEGA,
178
- StandardPrefixes.MILLI
179
- ],
180
- 'siemens': [
181
- StandardPrefixes.MILLI,
182
- StandardPrefixes.MICRO
183
- ],
184
- 'weber': [
185
- StandardPrefixes.MILLI,
186
- StandardPrefixes.MICRO
187
- ],
188
- 'tesla': [
189
- StandardPrefixes.MILLI,
190
- StandardPrefixes.MICRO,
191
- StandardPrefixes.NANO
192
- ],
193
- 'henry': [
194
- StandardPrefixes.MILLI,
195
- StandardPrefixes.MICRO,
196
- StandardPrefixes.NANO
197
- ],
198
- 'lumen': [],
199
- 'lux': [],
200
- 'becquerel': [
201
- StandardPrefixes.KILO,
202
- StandardPrefixes.MEGA,
203
- StandardPrefixes.GIGA
204
- ],
205
- 'gray': [
206
- StandardPrefixes.MILLI,
207
- StandardPrefixes.MICRO
208
- ],
209
- 'sievert': [
210
- StandardPrefixes.MILLI,
211
- StandardPrefixes.MICRO
212
- ],
213
- 'hertz': [
214
- StandardPrefixes.KILO,
215
- StandardPrefixes.MEGA,
216
- StandardPrefixes.GIGA
217
- ],
218
- 'newton': [
219
- StandardPrefixes.KILO,
220
- StandardPrefixes.MILLI
221
- ],
222
- 'bar': [
223
- StandardPrefixes.MILLI
224
- ], # Common non-SI unit
225
- 'liter': [
226
- StandardPrefixes.MILLI,
227
- StandardPrefixes.MICRO
228
- ], # Common non-SI unit
229
- }
qnty/unit_types/base.py DELETED
@@ -1,47 +0,0 @@
1
- """
2
- Base Unit Module Definition
3
- ===========================
4
-
5
- Provides abstract base class for unit modules and registration functionality.
6
- """
7
-
8
- from abc import ABC, abstractmethod
9
- from typing import Any
10
-
11
- from ..unit import UnitDefinition
12
-
13
-
14
- class UnitModule(ABC):
15
- """Abstract base class for unit modules."""
16
-
17
- @abstractmethod
18
- def get_unit_definitions(self) -> list[UnitDefinition]:
19
- """Return list of unit definitions for this module."""
20
- pass
21
-
22
- @abstractmethod
23
- def get_units_class(self) -> type[Any]:
24
- """Return the units class for this module."""
25
- pass
26
-
27
- def register_to_registry(self, unit_registry):
28
- """Register all unit definitions to the given registry."""
29
- from ..unit import UnitConstant
30
-
31
- for unit_def in self.get_unit_definitions():
32
- if unit_def.name not in unit_registry.units:
33
- unit_registry.register_unit(unit_def)
34
-
35
- # Populate the units class with constants from registry
36
- units_class = self.get_units_class()
37
- for unit_def in self.get_unit_definitions():
38
- unit_constant = UnitConstant(unit_registry.units[unit_def.name])
39
- setattr(units_class, unit_def.name, unit_constant)
40
-
41
- # Add any aliases
42
- if unit_def.symbol and unit_def.symbol != unit_def.name:
43
- setattr(units_class, unit_def.symbol, unit_constant)
44
-
45
- # Special case for inch - add in_ alias since 'in' is a Python keyword
46
- if unit_def.name == "inch":
47
- units_class.in_ = unit_constant