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

Quantity: add dunder methods #8

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

andrewgsavage
Copy link

transferred from quantity-dev/quantity-api#6

@lucascolley lucascolley changed the title Quantity dunders Quantity: add dunder methods Mar 17, 2025
@lucascolley lucascolley linked an issue Mar 17, 2025 that may be closed by this pull request
Copy link
Member

@lucascolley lucascolley left a 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?

@andrewgsavage
Copy link
Author

I feel like we need to get a type checker going to know what works and doesnt

@lucascolley
Copy link
Member

lucascolley commented Mar 17, 2025

I feel like we need to get a type checker going to know what works and doesnt

Yes, but we then also need a minimal an implementation to check against :)

@andrewgsavage
Copy link
Author

I feel like we need to get a type checker going to know what works and doesnt

Yes, but we then also need a minimal implementation to check against :)

does it have to be minimal? would a fork of pint (or another module) work?

@lucascolley
Copy link
Member

would a fork of pint (or another module) work?

yeah, I think so!

@jorenham
Copy link

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?

My mental typechecker did not report any errors 👌🏻

@jorenham
Copy link

I feel like we need to get a type checker going to know what works and doesnt

Exactly; writing annotations without a type-checker is like programming without a compiler or interpreter

andrewgsavage and others added 4 commits March 18, 2025 22:35
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>
def __gt__[B](self: "Quantity[V, U]", other: "Quantity[op.CanOrd[V, B], U]", /) -> B: ...
def __ge__[B](self: "Quantity[V, U]", other: "Quantity[op.CanOrd[V, B], U]", /) -> B: ...

def __pos__[R](self: "Quantity[op.CanPos[R], U]") -> "Quantity[R, U]": ...

Choose a reason for hiding this comment

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

When would R in __pos__ ever not be V? I can't think of any examples. 🧐

Choose a reason for hiding this comment

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

>>> +True
1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Quantity: dunder methods
4 participants