Skip to content

Commit

Permalink
Second attempt, now add a try...except
Browse files Browse the repository at this point in the history
this should catch occurrences like `'d' | units.Myr`, as in mesa's interface...
  • Loading branch information
rieder committed Mar 7, 2023
1 parent bda91f8 commit f4b5184
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/amuse/units/quantities.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,11 @@ def __init__(self, number, unit):
# Quantity.__init__(self, unit)
# commented out super call, this speeds thing up
self.unit = unit
if isinstance(number, str):
try:
number = float(number)
except ValueError: # needed to handle interfaces
pass
if unit.dtype is None:
self.number = number
else:
Expand Down

0 comments on commit f4b5184

Please sign in to comment.