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

Support dimensionality checking #2

Open
mikemhenry opened this issue Sep 6, 2022 · 1 comment
Open

Support dimensionality checking #2

mikemhenry opened this issue Sep 6, 2022 · 1 comment

Comments

@mikemhenry
Copy link
Contributor

It would be nice to support something like:

class Atom(DefaultModel):
    mass: FloatQuantity["mass"]

And then we would accept any unit that has dimensionality "mass".
Same would go for "length" so then we would accept "nm", "angstrom", etc

something like hgrecco/pint#1166 (comment)

@mattwthompson
Copy link
Member

We could possibly do these as separate classes (ideally with a better name than this):

class Thing(DefaultModel):
    mass: FloatQuantity["mass"]
    some_physical_property: FloatQuantityThatOnlySpecifiesDimensionality['temperature']

It's not clear if these functionalities could be handled by the same class, and maybe it's better if they are handled by separate classes. In general this would be great for situations in which you don't care which unit is used (i.e. you will do the appropriate Quantity.magnitude_as conversions) but it is important that you don't try to measure a mass with Kelving.

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