qnty 0.0.9__py3-none-any.whl → 0.1.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. qnty/__init__.py +2 -3
  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 +1 -1
  12. qnty/equations/equation.py +118 -155
  13. qnty/equations/system.py +68 -65
  14. qnty/expressions/__init__.py +25 -46
  15. qnty/expressions/formatter.py +188 -0
  16. qnty/expressions/functions.py +46 -68
  17. qnty/expressions/nodes.py +540 -384
  18. qnty/expressions/types.py +70 -0
  19. qnty/problems/__init__.py +145 -0
  20. qnty/problems/composition.py +1101 -0
  21. qnty/problems/problem.py +737 -0
  22. qnty/problems/rules.py +145 -0
  23. qnty/problems/solving.py +1216 -0
  24. qnty/problems/validation.py +127 -0
  25. qnty/quantities/__init__.py +28 -5
  26. qnty/quantities/base_qnty.py +677 -0
  27. qnty/quantities/field_converters.py +24004 -0
  28. qnty/quantities/field_qnty.py +1012 -0
  29. qnty/{generated/setters.py → quantities/field_setter.py} +3071 -2961
  30. qnty/{generated/quantities.py → quantities/field_vars.py} +829 -444
  31. qnty/{generated/quantities.pyi → quantities/field_vars.pyi} +1289 -1290
  32. qnty/solving/manager.py +50 -44
  33. qnty/solving/order.py +181 -133
  34. qnty/solving/solvers/__init__.py +2 -9
  35. qnty/solving/solvers/base.py +27 -37
  36. qnty/solving/solvers/iterative.py +115 -135
  37. qnty/solving/solvers/simultaneous.py +93 -165
  38. qnty/units/__init__.py +1 -0
  39. qnty/{generated/units.py → units/field_units.py} +1700 -991
  40. qnty/units/field_units.pyi +2461 -0
  41. qnty/units/prefixes.py +58 -105
  42. qnty/units/registry.py +76 -89
  43. qnty/utils/__init__.py +16 -0
  44. qnty/utils/caching/__init__.py +23 -0
  45. qnty/utils/caching/manager.py +401 -0
  46. qnty/utils/error_handling/__init__.py +66 -0
  47. qnty/utils/error_handling/context.py +39 -0
  48. qnty/utils/error_handling/exceptions.py +96 -0
  49. qnty/utils/error_handling/handlers.py +171 -0
  50. qnty/utils/logging.py +4 -4
  51. qnty/utils/protocols.py +164 -0
  52. qnty/utils/scope_discovery.py +420 -0
  53. {qnty-0.0.9.dist-info → qnty-0.1.1.dist-info}/METADATA +1 -1
  54. qnty-0.1.1.dist-info/RECORD +60 -0
  55. qnty/_backup/problem_original.py +0 -1251
  56. qnty/_backup/quantity.py +0 -63
  57. qnty/codegen/cli.py +0 -125
  58. qnty/codegen/generators/data/unit_data.json +0 -8807
  59. qnty/codegen/generators/data_processor.py +0 -345
  60. qnty/codegen/generators/dimensions_gen.py +0 -434
  61. qnty/codegen/generators/doc_generator.py +0 -141
  62. qnty/codegen/generators/out/dimension_mapping.json +0 -974
  63. qnty/codegen/generators/out/dimension_metadata.json +0 -123
  64. qnty/codegen/generators/out/units_metadata.json +0 -223
  65. qnty/codegen/generators/quantities_gen.py +0 -159
  66. qnty/codegen/generators/setters_gen.py +0 -178
  67. qnty/codegen/generators/stubs_gen.py +0 -167
  68. qnty/codegen/generators/units_gen.py +0 -295
  69. qnty/expressions/cache.py +0 -94
  70. qnty/generated/dimensions.py +0 -514
  71. qnty/problem/__init__.py +0 -91
  72. qnty/problem/base.py +0 -142
  73. qnty/problem/composition.py +0 -385
  74. qnty/problem/composition_mixin.py +0 -382
  75. qnty/problem/equations.py +0 -413
  76. qnty/problem/metaclass.py +0 -302
  77. qnty/problem/reconstruction.py +0 -1016
  78. qnty/problem/solving.py +0 -180
  79. qnty/problem/validation.py +0 -64
  80. qnty/problem/variables.py +0 -239
  81. qnty/quantities/expression_quantity.py +0 -314
  82. qnty/quantities/quantity.py +0 -428
  83. qnty/quantities/typed_quantity.py +0 -215
  84. qnty/validation/__init__.py +0 -0
  85. qnty/validation/registry.py +0 -0
  86. qnty/validation/rules.py +0 -167
  87. qnty-0.0.9.dist-info/RECORD +0 -63
  88. /qnty/{codegen → extensions}/__init__.py +0 -0
  89. /qnty/{codegen/generators → extensions/integration}/__init__.py +0 -0
  90. /qnty/{codegen/generators/utils → extensions/plotting}/__init__.py +0 -0
  91. /qnty/{generated → extensions/reporting}/__init__.py +0 -0
  92. {qnty-0.0.9.dist-info → qnty-0.1.1.dist-info}/WHEEL +0 -0
qnty/_backup/quantity.py DELETED
@@ -1,63 +0,0 @@
1
- """
2
- Public facade for quantity dimension classes.
3
-
4
- End users import:
5
- from qnty.quantity import Pressure, Length
6
- """
7
-
8
- from __future__ import annotations
9
-
10
- from typing import TYPE_CHECKING, Any
11
-
12
- # Explicit public API (trim as needed)
13
- __all__ = [
14
- "AbsorbedDose",
15
- "Pressure",
16
- "Length",
17
- "Temperature",
18
- "Force",
19
- "Area",
20
- "Volume",
21
- # ... add remaining exported dimension classes ...
22
- ]
23
-
24
- # Internal lazy module cache
25
- __generated_module: Any | None = None
26
-
27
-
28
- def _load():
29
- global __generated_module
30
- if __generated_module is None:
31
- from ..generated import quantities # local import for speed on cold start
32
- __generated_module = quantities
33
- return __generated_module
34
-
35
-
36
- # Inject attributes lazily
37
- def __getattr__(name: str):
38
- if name in __all__:
39
- mod = _load()
40
- try:
41
- return getattr(mod, name)
42
- except AttributeError:
43
- raise AttributeError(f"{name} not found in generated quantities") from None
44
- raise AttributeError(f"module 'qnty.quantities' has no attribute '{name}'")
45
-
46
-
47
- # Support dir() so tooling/REPLs see symbols
48
- def __dir__():
49
- return sorted(set(globals().keys()) | set(__all__))
50
-
51
-
52
- # Static type checking: directly import symbols so type checkers see them.
53
- if TYPE_CHECKING: # pragma: no cover
54
- from ..generated.quantities import (
55
- AbsorbedDose,
56
- Area,
57
- Force,
58
- Length,
59
- Pressure,
60
- Temperature,
61
- Volume,
62
- # ... mirror list in __all__ ...
63
- )
qnty/codegen/cli.py DELETED
@@ -1,125 +0,0 @@
1
- #!/usr/bin/env python3
2
- """
3
- Code Generation CLI
4
- ==================
5
-
6
- Command-line interface for generating all qnty files in the correct dependency order:
7
- 1. dimensions.py - Base dimensional constants
8
- 2. units.py - Unit class definitions
9
- 3. setters.py - Setter classes with unit properties
10
- 4. quantities.py - Quantity classes
11
- 5. quantities.pyi - Type stubs for IDE support
12
-
13
- Can be run from IDE or command line:
14
- - From command line: python cli.py
15
- - From IDE: Run this file directly
16
- """
17
-
18
- import subprocess
19
- import sys
20
- from pathlib import Path
21
-
22
-
23
- def run_generator(generator_name: str, script_path: Path) -> tuple[bool, str]:
24
- """Run a single generator script and return success status with output."""
25
- try:
26
- print(f"\n{'='*60}")
27
- print(f"Running {generator_name}...")
28
- print(f"{'='*60}")
29
-
30
- # Run the generator script as a module to allow relative imports
31
- module_name = f"qnty.codegen.generators.{script_path.stem}"
32
- result = subprocess.run(
33
- [sys.executable, "-m", module_name],
34
- capture_output=True,
35
- text=True,
36
- cwd=script_path.parents[4] # Run from project root
37
- )
38
-
39
- # Print the output
40
- if result.stdout:
41
- print(result.stdout)
42
-
43
- if result.stderr:
44
- print(f"STDERR: {result.stderr}")
45
-
46
- if result.returncode == 0:
47
- print(f"✓ {generator_name} completed successfully")
48
- return True, result.stdout
49
- else:
50
- print(f"✗ {generator_name} failed with return code {result.returncode}")
51
- return False, result.stderr
52
-
53
- except Exception as e:
54
- error_msg = f"Error running {generator_name}: {str(e)}"
55
- print(error_msg)
56
- return False, error_msg
57
-
58
-
59
- def main() -> int:
60
- """Main CLI function that runs all generators in dependency order."""
61
- print("Qnty Code Generation Pipeline")
62
- print("============================")
63
- print("Generating all files in dependency order...")
64
-
65
- # Get the generators subdirectory
66
- script_dir = Path(__file__).parent / "generators"
67
-
68
- # Define generators in dependency order
69
- generators: list[tuple[str, str]] = [
70
- ("Dimensions Generator", "dimensions_gen.py"),
71
- ("Units Generator", "units_gen.py"),
72
- ("Setters Generator", "setters_gen.py"),
73
- ("Quantities Generator", "quantities_gen.py"),
74
- ("Type Stubs Generator", "stubs_gen.py"),
75
- ]
76
-
77
- # Track results
78
- success_count = 0
79
- total_count = len(generators)
80
- failed_generators = []
81
-
82
- # Run each generator in order
83
- for generator_name, script_name in generators:
84
- script_path = script_dir / script_name
85
-
86
- if not script_path.exists():
87
- print(f"✗ {generator_name}: Script not found at {script_path}")
88
- failed_generators.append(generator_name)
89
- continue
90
-
91
- success, output = run_generator(generator_name, script_path)
92
- if success:
93
- success_count += 1
94
- else:
95
- failed_generators.append(generator_name)
96
- print(f"Output: {output}")
97
-
98
- # Print final summary
99
- print(f"\n{'='*60}")
100
- print("GENERATION SUMMARY")
101
- print(f"{'='*60}")
102
- print(f"Successful: {success_count}/{total_count}")
103
-
104
- if failed_generators:
105
- print(f"Failed: {', '.join(failed_generators)}")
106
- return 1
107
- else:
108
- print("✓ All generators completed successfully!")
109
- print("\nGenerated files:")
110
- print(" - src/qnty/generated/dimensions.py")
111
- print(" - src/qnty/generated/units.py")
112
- print(" - src/qnty/generated/setters.py")
113
- print(" - src/qnty/generated/quantities.py")
114
- print(" - src/qnty/generated/quantities.pyi")
115
- return 0
116
-
117
-
118
- if __name__ == "__main__":
119
- exit_code = main()
120
-
121
- # If running from IDE, pause so user can see results
122
- if hasattr(sys, 'ps1') or 'idlelib' in sys.modules or 'IPython' in sys.modules:
123
- input("\nPress Enter to continue...")
124
-
125
- sys.exit(exit_code)