Skip to content

Commit

Permalink
Fix bug with saving compound units
Browse files Browse the repository at this point in the history
  • Loading branch information
jgeldart committed Sep 1, 2018
1 parent e412db0 commit dea392d
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions quantity_field/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,9 @@ def from_string(cls, data):
Example:
>>> mq = MultiQuantity.from_string('2.0*5.5*4.0 meter')
"""

packed_values = data.split(cls.SEPARATOR)
packed_values = packed_values[:-1] + packed_values[-1].split()
packed_values = [float(v) for v in packed_values[:-1]] + [packed_values[-1]]
parsed_quantity = Quantity(data)
unitless = data.replace(str(parsed_quantity.units), '')
packed_values = [float(v) for v in unitless.split(cls.SEPARATOR)] + [str(parsed_quantity.units)]

return cls.from_list(*packed_values)

Expand Down

0 comments on commit dea392d

Please sign in to comment.