def test_pow(): """Exponentiation of quantities.""" REGISTRY.clear() define_units() m_unit = unit('m') m_quant = Quantity(2, m_unit) assert (m_quant ** 2 == m_quant * m_quant == pow(m_quant, 2)) cm_unit = unit('cm') cm_quant = Quantity(2, cm_unit) assert within_epsilon(cm_quant ** 2, cm_quant * cm_quant) assert within_epsilon(cm_quant ** 2, pow(cm_quant, 2))
def can_make(unit_str): """True if the given unit string represents an SI unit.""" if prefixed(unit_str): unit = REGISTRY.get(without_prefix(unit_str), None) if unit: return unit.is_si() return False
def teardown_module(module): # Disable warning about not using module. # pylint: disable=W0613 """Called after running all of the tests here.""" REGISTRY.clear()