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

Attempt at replacing | with * for creating quantities #693

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
9 changes: 3 additions & 6 deletions src/amuse/units/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,9 @@ def __truediv__(self, other):
# return factor_unit(1.0 / other, self)

def __rmul__(self, other):
if other == 1:
return self
else:
if isinstance(other, unit):
return factor_unit(other, self)
return self.new_quantity(other)
if isinstance(other, unit):
return factor_unit(other, self)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is wrong, because factor units are supposed to construct from a number(like) and a unit..you should only get here with other a number..

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced it with mul_unit, I think that's correct?

return self.new_quantity(other)

def __ror__(self, value):
"""Create a new Quantity object.
Expand Down