MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / to

Method to

lib/matplotlib/tests/test_units.py:21–29  ·  view source on GitHub ↗
(self, new_units)

Source from the content-addressed store, hash-verified

19 self.units = units
20
21 def to(self, new_units):
22 factors = {('hours', 'seconds'): 3600, ('minutes', 'hours'): 1 / 60,
23 ('minutes', 'seconds'): 60, ('feet', 'miles'): 1 / 5280.,
24 ('feet', 'inches'): 12, ('miles', 'inches'): 12 * 5280}
25 if self.units != new_units:
26 mult = factors[self.units, new_units]
27 return Quantity(mult * self.magnitude, new_units)
28 else:
29 return Quantity(self.magnitude, self.units)
30
31 def __copy__(self):
32 return Quantity(self.magnitude, self.units)

Callers 1

convertFunction · 0.80

Calls 1

QuantityClass · 0.85

Tested by

no test coverage detected