コード例 #1
0
 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)))
コード例 #2
0
 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)
コード例 #3
0
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"))
コード例 #4
0
ファイル: length.py プロジェクト: the-nick-of-time/units
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"))
コード例 #5
0
 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)
コード例 #6
0
 def test_self_reference(self):
     dim = make_dimension("TEST")
     self.assertIs(dim, dim.DIMENSION)
コード例 #7
0
 def setUp(self):
     self.dimension = make_dimension("TEST")
コード例 #8
0
ファイル: time.py プロジェクト: the-nick-of-time/units
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"))
コード例 #9
0
 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)
コード例 #10
0
 def setUp(self):
     self.dimension = make_dimension("TEST")
     self.first = make_unit("first", self.dimension, 1)
     self.second = make_unit("second", self.dimension, 10)