-
Notifications
You must be signed in to change notification settings - Fork 3
Quantity: add dunder methods #8
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
Conversation
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.
I've added some tentative suggestions but I'm not sure that they are correct — @jorenham do my suggestions look closer to what we would want here?
I feel like we need to get a type checker going to know what works and doesnt |
Yes, but we then also need |
does it have to be minimal? would a fork of pint (or another module) work? |
yeah, I think so! |
My mental typechecker did not report any errors 👌🏻 |
Exactly; writing annotations without a type-checker is like programming without a compiler or interpreter |
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.
the linked issue also suggests:
__floordiv__
,__mod__
,__divmod__
, shifts, &, ^, |, ...
7623c3f
to
5eed30f
Compare
type checkers are happy! Any opinions on #5 (comment) @nstarman @neutrinoceros ? |
Co-authored-by: Lucas Colley <lucas.colley8@gmail.com>
Co-authored-by: Lucas Colley <lucas.colley8@gmail.com>
Co-authored-by: Lucas Colley <lucas.colley8@gmail.com>
Co-authored-by: Lucas Colley <lucas.colley8@gmail.com>
763dc6d
to
0f7ec35
Compare
alright, let's get this in, we can always revisit other methods as and when need arises. thanks all! |
oh I meant to ask if we want to keep rpow |
I think so. If we can do |
that only makes sense for a unitless quantity, you shouldn't be able to do 2 ** Quantity(2, "m"). I think its reasonable for a library to implement this or not implement it |
ah yeah, good point, we should probably remove it then |
not sure if it's a thing, but maybe it makes sense for logarithmic units like decibels? |
Agreed. This feels like an API vs implementation issue. If you have access to the runtime, which we do not, then you can distinguish between dimensionful and dimensionless quantities. |
transferred from quantity-dev/quantity-api#6