-
Notifications
You must be signed in to change notification settings - Fork 2
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
Conversation
…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
…that are not classes.
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'
Codecov ReportAttention: Patch coverage is
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…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'
override it and remove its units. Now, it just return the Class
itself,
to the unit that was specificed on the Field. This requires
base__unit to exists.
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'