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

High-value type hints for Quantity #35

Open
Yoshanuikabundi opened this issue Jun 4, 2022 · 1 comment
Open

High-value type hints for Quantity #35

Yoshanuikabundi opened this issue Jun 4, 2022 · 1 comment

Comments

@Yoshanuikabundi
Copy link
Contributor

Yoshanuikabundi commented Jun 4, 2022

It would be amazing to be able to specify the shape and units of a Quantity[Array] in type hints, does anyone know if that's possible? I know they're both part of the value and not the type but the two concepts are kinda fungible in Python. I vaguely remember that people somewhere somewhen were working on it.

It would be great to have some really high-quality type hints for Quantity. Ideally, we'd be able to express the dimensions of the quantity, as well as the enclosed type. This would allow units to be checked statically, which would be huge. In a perfect world, NumPy would support type hints on arrays that specify their dtype and shape, but maybe if they drag on that we can do something for Quantity[Array]

This all probably requires PEP 646, which is to be implemented in Python 3.11, so won't be safe for us to use for another couple of years unless someone develops a back-port.

@mattwthompson
Copy link
Member

This can be revisited sometime in early 2025, otherwise we're stuck on things that can work on Python 3.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

No branches or pull requests

2 participants