Closed yunruse closed 2 months ago
Done. Measure
now works with the functions __int__
, __float__
, __round__
, .real
, .imag
, .numerator
, .denominator
, .conjugate
, .as_integer_ratio
.
MeasureRelative
works based on the unit provided. It also 'rounds into' the unit, so:
>>> round(month(2) @ year, 3)
60 d + 23 hr + 55 min + 19.2 s # time
>>> round(month(2) / year, 3)
0.167
but otherwise @
and /
are identical for the remaining functions. It feels subtly inconsistent, however, which might be a tripping hazard.
In development I noticed the .value
property is used a concerning amount. It's just the underlying representative in base units (i.e. SI) but a bit… hackily in places. Lower priority, perhaps..?
General info
round() doesn't work on
Measure
(or any of its subclasses).Python 3.12.1 noether==1.1
Steps
Expected behaviour
Measure @ unit
ORMeasure / unit
should produce the same result underround()
. In other words:Measure: round the value if and only if dimensionless - it is ambiguous otherwise! MeasureRelative: always round based on the unit. That is:
Indeed we might want to tighten
__int__
and__float__
to work in the exact same way.