Skip to content

Commit ecb650d

Browse files
Refactor uncertainty calculator modules and update imports
Renamed and reorganized several modules for clarity and consistency: - `parsing.py` is now `parsers.py` - `rendering.py` is now `render.py` - `types.py` is now `_types.py` Additionally, updated all relevant imports across the codebase to reflect these changes. Removed obsolete `formatting.py` and `parsing.py` files to streamline the project structure. This refactor aims to enhance code organization and maintainability.
1 parent 28a0ec0 commit ecb650d

15 files changed

Lines changed: 41 additions & 41 deletions

File tree

.cursor/rules/uncertainty-calculator.mdc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ alwaysApply: true
77

88
- Keep the canonical flow: `parse_inputs()` -> `validate_inputs()` -> `compute()` -> `render_output()`.
99
- Keep module boundaries strict:
10-
- `parsing.py`: input normalization and symbol/value maps
10+
- `parsers.py`: input normalization and symbol/value maps
1111
- `validation.py`: invalid/missing symbol checks
1212
- `compute.py`: derivatives and uncertainty propagation math
13-
- `rendering.py`: LaTeX assembly and layout modes
14-
- `formatting.py`: shared SymPy-to-LaTeX helper wrappers
13+
- `render.py`: LaTeX assembly and layout modes
14+
- `format.py`: shared SymPy-to-LaTeX helper wrappers
1515

1616
## Safety and Compatibility
1717

AGENTS.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99

1010
## Core Pipeline (Do Not Bypass)
1111

12-
1. `parse_inputs()` in `src/uncertainty_calculator/parsing.py`
12+
1. `parse_inputs()` in `src/uncertainty_calculator/parsers.py`
1313
2. `validate_inputs()` in `src/uncertainty_calculator/validation.py`
1414
3. `compute()` in `src/uncertainty_calculator/compute.py`
15-
4. `render_output()` in `src/uncertainty_calculator/rendering.py`
15+
4. `render_output()` in `src/uncertainty_calculator/render.py`
1616

1717
Keep logic in the right layer. Prefer extending an existing stage over mixing concerns across modules.
1818

@@ -25,11 +25,11 @@ Keep logic in the right layer. Prefer extending an existing stage over mixing co
2525

2626
## Module Ownership
2727

28-
- `parsing.py`: normalize and map inputs into SymPy-friendly structures.
28+
- `parsers.py`: normalize and map inputs into SymPy-friendly structures.
2929
- `validation.py`: reject undefined or invalid symbolic references.
3030
- `compute.py`: derivatives and numeric uncertainty propagation.
31-
- `rendering.py`: LaTeX structure/format (combined vs separate, insert vs non-insert).
32-
- `formatting.py`: SymPy-to-LaTeX helper wrappers only.
31+
- `render.py`: LaTeX structure/format (combined vs separate, insert vs non-insert).
32+
- `format.py`: SymPy-to-LaTeX helper wrappers only.
3333

3434
## Change Rules
3535

CLAUDE.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ produce LaTeX that includes evaluated value and propagated uncertainty, plus opt
1818

1919
## Key Compatibility Constraints
2020

21-
- Preserve the dataclass API in `src/uncertainty_calculator/types.py`.
21+
- Preserve the dataclass API in `src/uncertainty_calculator/_types.py`.
2222
- Preserve orchestration contract in `src/uncertainty_calculator/calculator.py`.
2323
- Treat output format as regression-sensitive; tests compare against legacy behavior.
2424

2525
## Where to Edit
2626

27-
- Parsing or symbol mapping changes: `parsing.py`
27+
- Parsing or symbol mapping changes: `parsers.py`
2828
- Validation rules: `validation.py`
2929
- Derivative or uncertainty math: `compute.py`
30-
- LaTeX layout/output switches: `rendering.py`
31-
- LaTeX helper options: `formatting.py`
30+
- LaTeX layout/output switches: `render.py`
31+
- LaTeX helper options: `format.py`
3232

3333
## Test Discipline
3434

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ The calculator is designed to be used as a Python module. Below is a complete ex
6464
The core logic is organized by responsibility:
6565

6666
- `calculator.py`: orchestrates the pipeline
67-
- `parsing.py`: builds symbols/mappings from inputs
67+
- `parsers.py`: builds symbols/mappings from inputs
6868
- `compute.py`: performs derivatives and numeric propagation
69-
- `rendering.py`: produces LaTeX output
70-
- `types.py`: input dataclasses and type aliases
71-
- `formatting.py` / `validation.py`: shared helpers
69+
- `render.py`: produces LaTeX output
70+
- `_types.py`: input dataclasses and type aliases
71+
- `format.py` / `validation.py`: shared helpers
7272

7373
### 1. Define the Equation
7474

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Uncertainty Calculator Package."""
22

3+
from uncertainty_calculator._types import Digits, Equation, Variable, Variables
34
from uncertainty_calculator.calculator import UncertaintyCalculator
4-
from uncertainty_calculator.types import Digits, Equation, LastUnit, Variable, Variables
55

6-
__version__ = "0.1.1"
7-
__all__ = ["Digits", "Equation", "LastUnit", "UncertaintyCalculator", "Variable", "Variables"]
6+
__version__ = "0.1.2"
7+
__all__ = ["Digits", "Equation", "UncertaintyCalculator", "Variable", "Variables"]

src/uncertainty_calculator/calculator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
from uncertainty_calculator._types import Digits, Equation, Variables
66
from uncertainty_calculator.compute import ComputeState, compute
7-
from uncertainty_calculator.parsing import ParseState, parse_inputs
8-
from uncertainty_calculator.rendering import RenderOptions, render_output
7+
from uncertainty_calculator.parsers import ParseState, parse_inputs
8+
from uncertainty_calculator.render import RenderOptions, render_output
99
from uncertainty_calculator.validation import validate_inputs
1010

1111

src/uncertainty_calculator/compute.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
from sympy import S, diff, simplify, sqrt
99

1010
from uncertainty_calculator._types import Digits
11-
from uncertainty_calculator.formatting import latex_number
12-
from uncertainty_calculator.parsing import ParseState
11+
from uncertainty_calculator.format import latex_number
12+
from uncertainty_calculator.parsers import ParseState
1313

1414

1515
@dataclass
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Formatting helpers for LaTeX output."""
1+
"""Format helpers for LaTeX output."""
22

33
from __future__ import annotations
44

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
from sympy import Symbol, symbols, sympify
1010

1111
from uncertainty_calculator._types import Equation, Variables
12-
from uncertainty_calculator.formatting import latex_number
12+
from uncertainty_calculator.format import latex_number
1313

1414

1515
@dataclass
1616
class ParseState:
17-
"""Intermediate parsed inputs ready for computation/rendering."""
17+
"""Intermediate parsed inputs ready for computation/render."""
1818

1919
symbols: list[Symbol]
2020
unc_symbols: list[Symbol]
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Rendering helpers for the uncertainty calculator."""
1+
"""Render helpers for the uncertainty calculator."""
22

33
from __future__ import annotations
44

@@ -7,13 +7,13 @@
77
from dataclasses import dataclass
88

99
from uncertainty_calculator.compute import ComputeState
10-
from uncertainty_calculator.formatting import latex_number, latex_symbol, latex_value
11-
from uncertainty_calculator.parsing import ParseState
10+
from uncertainty_calculator.format import latex_number, latex_symbol, latex_value
11+
from uncertainty_calculator.parsers import ParseState
1212

1313

1414
@dataclass
1515
class RenderOptions:
16-
"""Rendering configuration for the output."""
16+
"""Render configuration for the output."""
1717

1818
last_unit: str | None
1919
separate: bool

0 commit comments

Comments
 (0)