Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed error of pint from previous commit and added new functionality #26

Merged
merged 9 commits into from
May 29, 2024

Conversation

pesap
Copy link
Collaborator

@pesap pesap commented May 24, 2024

  • Fixed an issue where if we passes a BaseQuantiy it will try to
    override it and remove its units. Now, it just return the Class
    itself,
  • Added new functionallity to pass any float or int and will convert it
    to the unit that was specificed on the Field. This requires
    base__unit to exists.
  • Added better serialization where we can pass custom dictionary to
    change the serialization of a pint.Quantity. By default, it return a
    string of the quantity (e.g. '10 volt'), but now if we just want to
    export the magnitude we pass
    .model_dump(context={"magnitude_only":True}) will return '10'

pesap added 7 commits May 24, 2024 00:52
…ions

List of changes:
- Removed `__new__` from BaseQuantity
- Added `ureg.check` to default units. This will check if the unit is compatible, but will not check the input value.
- Added testing for BaseQuantity class and units.

Issue #24
BaseQuantity.

List of changes:
- Fixed an issue where if we passes a BaseQuantiy it will try to
  override it and remove its units. Now, it just return the Class
  itself,
- Added new functionallity to pass any float or int and will convert it
  to the unit that was specificed on the Field. This requires
  __base__unit__ to exists.
- Added better serialization where we can pass custom dictionary to
  change the serialization of a pint.Quantity. By default, it return a
  string of the quantity (e.g. '10 volt'), but now if we just want to
  export the magnitude we pass
  `.model_dump(context={"magnitude_only":True})` will return '10'
@pesap pesap self-assigned this May 24, 2024
@codecov-commenter
Copy link

codecov-commenter commented May 24, 2024

Codecov Report

Attention: Patch coverage is 94.82759% with 3 lines in your changes missing coverage. Please review.

Project coverage is 95.88%. Comparing base (dd818c2) to head (f487f46).
Report is 23 commits behind head on main.

Files with missing lines Patch % Lines
src/infrasys/base_quantity.py 88.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #26      +/-   ##
==========================================
+ Coverage   95.44%   95.88%   +0.44%     
==========================================
  Files          25       25              
  Lines        2131     2165      +34     
==========================================
+ Hits         2034     2076      +42     
+ Misses         97       89       -8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pesap pesap requested a review from daniel-thom May 29, 2024 04:13
Copy link
Collaborator

@daniel-thom daniel-thom left a comment

Choose a reason for hiding this comment

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

LGTM

@pesap pesap linked an issue May 29, 2024 that may be closed by this pull request
@pesap pesap merged commit 25a110a into main May 29, 2024
6 checks passed
@pesap pesap deleted the ps/pint branch May 29, 2024 16:38
github-actions bot pushed a commit that referenced this pull request May 29, 2024
…ctionality (#26)

List of changes:
- Fixed an issue where if we passes a BaseQuantiy it will try to
  override it and remove its units. Now, it just return the Class
  itself,
- Added new functionallity to pass any float or int and will convert it
  to the unit that was specificed on the Field. This requires
  __base__unit__ to exists.
- Added better serialization where we can pass custom dictionary to
  change the serialization of a pint.Quantity. By default, it return a
  string of the quantity (e.g. '10 volt'), but now if we just want to
  export the magnitude we pass
  `.model_dump(context={"magnitude_only":True})` will return '10'
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.

bug: pint unit definitions are not capable of performing multiplications
3 participants