def test_prefix_operations(): m = PREFIXES['m'] k = PREFIXES['k'] M = PREFIXES['M'] dodeca = Prefix('dodeca', 'dd', 1, base=12) assert m * k == 1 assert k * k == M assert 1 / m == k assert k / m == M assert dodeca * dodeca == 144 assert 1 / dodeca == 1 / 12 assert k / dodeca == 1000 / 12 assert dodeca / dodeca == 1 m = Quantity("meter", 1, 6) assert dodeca / m == 12 / m expr1 = kilo*3 assert isinstance(expr1, Mul) assert (expr1).args == (3, kilo) expr2 = kilo*x assert isinstance(expr2, Mul) assert (expr2).args == (x, kilo)
def test_prefix_operations(): m = PREFIXES['m'] k = PREFIXES['k'] M = PREFIXES['M'] dodeca = Prefix('dodeca', 'dd', 1, base=12) assert m * k == 1 assert k * k == M assert 1 / m == k assert k / m == M assert dodeca * dodeca == 144 assert 1 / dodeca == 1 / 12 assert k / dodeca == 1000 / 12 assert dodeca / dodeca == 1 m = Quantity("meter", 1, 6) assert dodeca / m == 12 / m
def test_prefix_operations(): m = PREFIXES["m"] k = PREFIXES["k"] M = PREFIXES["M"] dodeca = Prefix("dodeca", "dd", 1, base=12) assert m * k == 1 assert k * k == M assert 1 / m == k assert k / m == M assert dodeca * dodeca == 144 assert 1 / dodeca == S.One / 12 assert k / dodeca == S(1000) / 12 assert dodeca / dodeca == 1 m = Quantity("fake_meter") SI.set_quantity_dimension(m, S.One) SI.set_quantity_scale_factor(m, S.One) assert dodeca * m == 12 * m assert dodeca / m == 12 / m expr1 = kilo * 3 assert isinstance(expr1, Mul) assert expr1.args == (3, kilo) expr2 = kilo * x assert isinstance(expr2, Mul) assert expr2.args == (x, kilo) expr3 = kilo / 3 assert isinstance(expr3, Mul) assert expr3.args == (Rational(1, 3), kilo) assert expr3.args == (S.One / 3, kilo) expr4 = kilo / x assert isinstance(expr4, Mul) assert expr4.args == (1 / x, kilo)
def test_prefix_operations(): m = PREFIXES['m'] k = PREFIXES['k'] M = PREFIXES['M'] dodeca = Prefix('dodeca', 'dd', 1, base=12) assert m * k == 1 assert k * k == M assert 1 / m == k assert k / m == M assert dodeca * dodeca == 144 assert 1 / dodeca == S.One / 12 assert k / dodeca == S(1000) / 12 assert dodeca / dodeca == 1 m = Quantity("fake_meter") m.set_dimension(S.One) m.set_scale_factor(S.One) assert dodeca * m == 12 * m assert dodeca / m == 12 / m expr1 = kilo * 3 assert isinstance(expr1, Mul) assert (expr1).args == (3, kilo) expr2 = kilo * x assert isinstance(expr2, Mul) assert (expr2).args == (x, kilo) expr3 = kilo / 3 assert isinstance(expr3, Mul) assert (expr3).args == (Rational(1, 3), kilo) assert (expr3).args == (S.One / 3, kilo) expr4 = kilo / x assert isinstance(expr4, Mul) assert (expr4).args == (1 / x, kilo)