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
To handle better more complex cases of Units, like : kg/cm^2
(that would be UnitsQuotient(Unit('kg'), Unit('cm', exponent=Number(2))).
This will be then necessary to adapt the Number class (in particular, a part of the code of __mul__, __truediv__... should certainly be moved to these new classes' code; the NotImplementedError should be removed; tests like isinstance(..., Unit), if any, might need to be replaced by isinstance(..., (Unit, UnitsProduct, UnitsQuotient))) in order to use these new objects.
The tests (in numbers_test.py) should remain the same except the ones that control the NotImplementedError, that should be changed and moved from the test_..._errors() functions to the "normal" test_...() functions.
Neither UnitsProduct nor UnitsQuotients should inherit from Unit (because they are not like a single Exponented), but they might inherit from a common abstract class (DerivedUnit?) in order to simplify the instance tests (isinstance(..., (Unit, DerivedUnit)) would be enough).
Finally, complete the Units handling in so far unsupported operations, where it does make sense (Units get lost when using floor division (//) or divmod etc.).
The text was updated successfully, but these errors were encountered:
To handle better more complex cases of Units, like : kg/cm^2
(that would be
UnitsQuotient(Unit('kg'), Unit('cm', exponent=Number(2))
).This will be then necessary to adapt the Number class (in particular, a part of the code of
__mul__
,__truediv__
... should certainly be moved to these new classes' code; theNotImplementedError
should be removed; tests likeisinstance(..., Unit)
, if any, might need to be replaced byisinstance(..., (Unit, UnitsProduct, UnitsQuotient))
) in order to use these new objects.The tests (in
numbers_test.py
) should remain the same except the ones that control theNotImplementedError
, that should be changed and moved from thetest_..._errors()
functions to the "normal"test_...()
functions.Neither
UnitsProduct
norUnitsQuotients
should inherit fromUnit
(because they are not like a singleExponented
), but they might inherit from a common abstract class (DerivedUnit
?) in order to simplify the instance tests (isinstance(..., (Unit, DerivedUnit))
would be enough).Finally, complete the Units handling in so far unsupported operations, where it does make sense (Units get lost when using floor division (
//
) ordivmod
etc.).The text was updated successfully, but these errors were encountered: