You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When durations are represented as string, they may be negative. As a user, I expect these to be valid when passed to the from_str function (or to the initializer in Python). However, that leads to an InvalidTimezone error.
For example, from python:
>>>Duration("-1 h 6 s")
---------------------------------------------------------------------------HifitimeErrorTraceback (mostrecentcalllast)
CellIn[12], line1---->1Duration("-1 h 6 s")
HifitimeError: InvalidTimezone, invalidtimezoneformat [+/-]HH:MM
This issue should also export the neg function to Python. Until then, the only way to negate a duration in Python is by the unnecessarily complicated: Duration.ZERO() - Duration("1 h 6 min") or Unit.Second*(-Duration("1 h 6 min").to_seconds()).
Finally, the from_str function should also support the UTF8 characters used in the formatting, like the micro:
In [32]: value_str = "-54 ms 102 μs 616 ns"
In [33]: Duration(value_str[1:])
---------------------------------------------------------------------------
HifitimeError Traceback (most recent call last)
Cell In[33], line 1
----> 1 Duration(value_str[1:])
HifitimeError: UnknownOrMissingUnit, unknown unit
The text was updated successfully, but these errors were encountered:
When durations are represented as string, they may be negative. As a user, I expect these to be valid when passed to the from_str function (or to the initializer in Python). However, that leads to an
InvalidTimezone
error.For example, from python:
This issue should also export the
neg
function to Python. Until then, the only way to negate a duration in Python is by the unnecessarily complicated:Duration.ZERO() - Duration("1 h 6 min")
orUnit.Second*(-Duration("1 h 6 min").to_seconds())
.Finally, the from_str function should also support the UTF8 characters used in the formatting, like the micro:
The text was updated successfully, but these errors were encountered: