-
Notifications
You must be signed in to change notification settings - Fork 89
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
Units as method attributes #933
Comments
I like the idea and can take part in implementing it. What do you think about automatically converting the units in the decorator if needed? That would allow us for getting rid of |
Yes, I was thinking the same. I tried sketching an implementation, but couldn't immediately find an elegant solution. But I'm sure we can think of something if the others agree it's worth pursuing. |
Interesting approach. I have the feeling you have been thinking deeper on this than me, @IvarStefansson, so let me know if you want to discuss at some point. Also, it would be good to have a roadmap for where we want to go with the units in a wider context before we start an implementation. |
Agreed. Yes, let's talk through this soon. |
Here is the minimal working example of how it can be implemented. If this looks good on the conceptual level to @keileg, @IvarStefansson and @IngridKJ, the rest of the work is just to insert it to all the parameters, which is mostly mechanical work.
|
Looks very good to me at first sight. |
Here is a sketch of how to track the derived quantities' units. I believe that's what @IvarStefansson originally wanted.
Which gives:
Currently, I used a global variable, however, something more elegant can be done, such as |
The issue is put on hold after the discussion with these key points:
|
Variables are tagged with units when created in a model. We have been thinking about providing units for parameters (and possibly derived quantities). So far, we have partially implemented this in the documentation. I've been thinking of ways to improve this which would allow automatic parsing. Here's a suggestion using a decorator:
Caveat: Mypy might not be thrilled.
The text was updated successfully, but these errors were encountered: