Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions scimath/units/quantity.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,7 @@ def propagate_data_changes(self):
return

# Replace the predecessor's data with converted data.
new_quantity = self.change_unit_system(predecessor.units)
predecessor.data = new_quantity.data
predecessor.data = units_convert(self.data, self.units, predecessor.units)

# Recursively continue propagating.
predecessor.propagate_data_changes()
Expand Down
9 changes: 9 additions & 0 deletions scimath/units/tests/test_units.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,15 @@ def test_propagation(self):
self.assertAlmostEqual(30., q1.data, 1,
"Propagation test expected data 30, got %s" % str(q1.data))

def test_propagation_to_imperial(self):
""" Tests data propagation for a single converted quantity. """

q1 = Quantity(10.0, units='ft', family_name='depth')
q2 = q1.change_unit_system('METRIC')
q2.data = 2 * q2.data
q2.propagate_data_changes()
self.assertAlmostEqual(q1.data, 20.0)

def test_get_original(self):

q1 = Quantity(10, units='m', family_name='depth')
Expand Down