-
Notifications
You must be signed in to change notification settings - Fork 144
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
Allow multiplication in duration input value #2845
Conversation
dd7a462
to
4d175d6
Compare
@lukaszachy do you plan to mention the version and/or include a release note? |
I wasn't but it is a very good point. |
|
ah, seems schema has the regexp as well, I need to change it. |
To make it easier for adjust the multiplication happens last: No need to pay attention how adjust creates the value.
Sorry for commenting late on this closed PR, but I think >>> import pint
>>> pint.Quantity("30 * 4 min")
<Quantity(120, 'minute')> Some care needs to be made with regards to translating |
That's right, I didn't think about using Pint for this task. I'm not sure if it would handle the ordering of operations @lukaszachy implemented though, it does not follow the mathematical ordering of multiplication and addition. |
Indeed, but the current one is also a bit hard to follow. It can look good with adjust:
duration+: 1h but the mathematical alternative is not bad either though: adjust:
duration+: + 1h I was hoping that >>> pint.Quantity("1h 40min")
<Quantity(40, 'hour * minute')>
>>> pint.Quantity("* 40min 1h")
Traceback (most recent call last): At least the first issue is straightforward to verify by adding a check for >>> pint.Quantity("1h 40min").dimensionality["[time]"]
2 |
To make it easier for adjust the multiplication happens last: No need to pay attention how adjust creates the value.
To make it easier for adjust the multiplication happens last: No need to pay attention how adjust creates the value.
To make it easier for adjust the multiplication happens last: No need to pay attention how adjust creates the value.
Only late I realized the input value for multiplication should accept float, so I will modify that later.
For now: does this approach will be accepted? It is preparation for #1843 so "adjust" doesn't need special handling of duration key.
Pull Request Checklist