Skip to content

Feat/temperature - #103

Open
parneetsingh022 wants to merge 15 commits into
mainfrom
feat/temperature
Open

Feat/temperature#103
parneetsingh022 wants to merge 15 commits into
mainfrom
feat/temperature

Conversation

@parneetsingh022

Copy link
Copy Markdown
Owner

No description provided.

- 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

codecov Bot commented Nov 2, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.64758% with 97 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/quantium/core/unit.py 70.37% 48 Missing ⚠️
src/quantium/core/quantity.py 85.26% 42 Missing ⚠️
src/quantium/io/unit_simplifier.py 91.89% 3 Missing ⚠️
src/quantium/units/registry.py 93.75% 3 Missing ⚠️
src/quantium/units/parser.py 95.23% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

- 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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Unit into LinearUnit (multiplicative) and AffineUnit (with offset)
  • Added AffineQuantity class for absolute temperature values
  • Implemented temperature difference units (Δ°C, Δ°F, Δ°R, ΔK) as LinearUnit instances
  • 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.

Comment thread src/quantium/core/unit.py Outdated
Comment thread tests/units/test_unit_namespace.py Outdated
Comment thread tests/core/quantity/test_affine_quantity.py
Comment thread tests/core/quantity/test_affine_quantity.py
Comment thread tests/core/quantity/test_affine_quantity.py
Comment thread src/quantium/core/unit.py
Comment thread src/quantium/core/unit.py
Comment thread src/quantium/core/unit.py
Comment thread src/quantium/core/unit.py
Comment thread src/quantium/core/unit.py
@parneetsingh022 parneetsingh022 self-assigned this Nov 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants