def setUp(self): self.simple_a = make_dimension("a") self.simple_b = make_dimension("b") self.dimension = make_compound_dimension("TEST", ((self.simple_a, 1), (self.simple_b, -1))) self.alt_dimension = make_compound_dimension("TESTAlt", ((self.simple_a, 1), (self.simple_b, -2)))
def test_equal_different_dimension(self): dim2 = make_dimension("dim2") first = make_unit("first", self.dimension, 1) a = first(1) second = make_unit("second", dim2, 1) b = second(1) with self.assertRaises(ImplicitConversionError): print(a == b)
from decimal import Decimal from base import make_dimension, make_unit Mass = make_dimension("Mass") kilograms = make_unit("kilograms", Mass, 1) grams = make_unit("grams", Mass, Decimal("0.001")) pounds = make_unit("pounds", Mass, Decimal("0.3732417216"))
from decimal import Decimal from base import make_unit, make_dimension Length = make_dimension("Length") meters = make_unit("meters", Length, 1) kilometers = make_unit("kilometers", Length, 1000) feet = make_unit("feet", Length, Decimal("0.3048"))
def setUp(self): self.dimA = make_dimension("FIRST") self.dimB = make_dimension("SECOND") self.unitA = make_unit("first", self.dimA, 1) self.unitB = make_unit("second", self.dimB, 1)
def test_self_reference(self): dim = make_dimension("TEST") self.assertIs(dim, dim.DIMENSION)
def setUp(self): self.dimension = make_dimension("TEST")
from decimal import Decimal from base import make_unit, make_dimension Time = make_dimension("Time") seconds = make_unit("seconds", Time, 1) minutes = make_unit("minutes", Time, 60) hours = make_unit("hours", Time, 60 * 60) days = make_unit("days", Time, 60 * 60 * 24) sidereal_days = make_unit("sidereal_days", Time, 60 * 60 * 23 + 60 * 56 + Decimal("4.091"))
def setUp(self): self.first_dimension = make_dimension("TEST1") self.second_dimension = make_dimension("TEST2") self.unit_1a = make_unit("unit_1a", self.first_dimension, 1) self.unit_1b = make_unit("unit_1b", self.first_dimension, 10) self.unit_2 = make_unit("unit_2", self.second_dimension, 1)
def setUp(self): self.dimension = make_dimension("TEST") self.first = make_unit("first", self.dimension, 1) self.second = make_unit("second", self.dimension, 10)