Feat/temperature - #103
Open
parneetsingh022 wants to merge 15 commits into
Open
Conversation
- Replaced instances of Unit with LinearUnit across various test files to ensure consistency in unit representation. - Updated tests for quantity arithmetic, equality, hashing, and SI conversion to reflect the new LinearUnit class. - Adjusted regression tests to specify LinearUnit where applicable, ensuring accurate testing of unit operations. - Modified test descriptions and comments to clarify the transition from Unit to LinearUnit.
- Updated references from Quantity to LinearQuantity in core, io, and test files. - Modified arithmetic operations, equality checks, and unit conversions to utilize LinearQuantity. - Ensured that all tests reflect the transition from Quantity to LinearQuantity, maintaining functionality and accuracy. - Adjusted regression tests to account for the new LinearQuantity behavior.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…d add delta temperature unit tests
- Added AffineQuantity class to represent absolute quantities in affine units (e.g., °C). - Updated LinearQuantity to handle operations with AffineQuantity, including addition and subtraction. - Implemented conversion methods for AffineQuantity to and from SI units. - Enhanced LinearUnit and AffineUnit classes to support new functionality and proper SI treatment. - Updated unit registry to include affine units for temperature (°C, °F, °R, K) and their delta counterparts (Δ°C, Δ°F, Δ°R). - Modified unit simplifier to linearize affine units in compositions. - Added comprehensive tests for AffineQuantity, ensuring correct arithmetic operations, conversions, and comparisons.
- Introduced AffineTemperatureOperationError to manage invalid operations involving affine temperature units (Celsius, Fahrenheit). - Updated LinearUnit class to allow multiplication and division with zero-offset affine units (Kelvin, Rankine) while raising errors for non-zero offset units. - Modified unit simplification logic to ensure proper handling of affine units in compositions. - Enhanced tests to cover new behaviors for linear and affine quantities, ensuring correct handling of operations involving temperature units. - Added support for Rankine as a valid unit in the registry.
parneetsingh022
force-pushed
the
feat/temperature
branch
from
November 6, 2025 02:49
da344ca to
723ff58
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR introduces support for affine temperature units (Celsius, Fahrenheit, Rankine) alongside linear units, implementing a two-tier unit system to properly handle temperature scales with offsets. Key changes include:
- Split
UnitintoLinearUnit(multiplicative) andAffineUnit(with offset) - Added
AffineQuantityclass for absolute temperature values - Implemented temperature difference units (Δ°C, Δ°F, Δ°R, ΔK) as
LinearUnitinstances - Added arithmetic rules preventing invalid operations with non-zero-offset affine units
Reviewed Changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 56 comments.
Show a summary per file
| File | Description |
|---|---|
src/quantium/core/unit.py |
Implements LinearUnit and AffineUnit classes with conversion methods |
src/quantium/core/quantity.py |
Adds AffineQuantity and updates LinearQuantity arithmetic to handle affine types |
src/quantium/units/registry.py |
Registers temperature units (both affine and delta) with aliases |
src/quantium/units/parser.py |
Updates parser to handle Unicode characters in unit symbols (Δ, °, µ) |
src/quantium/errors.py |
New error type for invalid affine temperature operations |
src/quantium/io/unit_simplifier.py |
Adds linearization helper for composition |
tests/core/quantity/test_affine_quantity.py |
Comprehensive test coverage for affine quantities (909 lines) |
tests/units/test_unit_registry.py |
Updates tests for LinearUnit references and adds delta temperature units |
| Multiple test files | Updates all imports from Unit to LinearUnit and Quantity to LinearQuantity |
Comments suppressed due to low confidence (2)
src/quantium/core/unit.py:407
- Implicit string concatenation. Maybe missing a comma?
__all__ = ["Unit", "LinearUnit", "AffineUnit" "UNIT_SIMPLIFIER"]
src/quantium/core/unit.py:407
- The name 'AffineUnitUNIT_SIMPLIFIER' is exported by all but is not defined.
__all__ = ["Unit", "LinearUnit", "AffineUnit" "UNIT_SIMPLIFIER"]
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…in LinearQuantity methods
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.