A Measure cannot be turned into a Fraction easily:
>>> a = (lunation % day) / day
>>> a
0.53058912
>>> Fraction(a)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/fractions.py", line 140, in __new__
raise TypeError("argument should be a string "
TypeError: argument should be a string or a Rational instance
We can see already that Measure is a Generic[T] where T is a Real. This could be extended; Measure should subclass the Real itself rather than holding it as its value.
This would vastly improve interoperability and also reduce the necessary methods added to keep Real compatibility (.imag, __int__ and so on).
Indeed it may be possible to later support the superclass Complex, though the methods dropped by this may cause some typing headaches.
A
Measure
cannot be turned into aFraction
easily:We can see already that
Measure
is aGeneric[T]
whereT
is aReal
. This could be extended;Measure
should subclass theReal
itself rather than holding it as its value.This would vastly improve interoperability and also reduce the necessary methods added to keep
Real
compatibility (.imag
,__int__
and so on).Indeed it may be possible to later support the superclass
Complex
, though the methods dropped by this may cause some typing headaches.