Skip to content
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

Introduce UnitsProduct and UnitsQuotients classes #1

Open
nicolashainaux opened this issue Nov 1, 2017 · 0 comments
Open

Introduce UnitsProduct and UnitsQuotients classes #1

nicolashainaux opened this issue Nov 1, 2017 · 0 comments

Comments

@nicolashainaux
Copy link
Owner

nicolashainaux commented Nov 1, 2017

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.).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant