Exemple #1
0
 def test_comparing_time_none_base_with_none_base_greater(self):
     t1 = quantity.Time(1., 'd')
     t2 = quantity.Time(23., 'h')
     self.assertFalse(t1 == t2)
     self.assertFalse(t1 <= t2)
     self.assertTrue(t1 >= t2)
     self.assertTrue(t1 > t2)
     self.assertFalse(t1 < t2)
     self.assertTrue(t1 != t2)
Exemple #2
0
    def test_time(self):
        t = quantity.Time(1.0, 's')

        self.assertEqual(t('ms'), float('1000.'))
        self.assertEqual(t('μs'), float('1e6'))
        self.assertAlmostEqual(t('ns'), float('1e9'), delta=1e-6)
        self.assertEqual(t('ps'), float('1e12'))
        self.assertAlmostEqual(t('fs'), float('1e15'), delta=1)
Exemple #3
0
    def test_time_233(self):
        t = quantity.Time(2.33, 's')

        self.assertEqual(t('ms'), float('2330.'))
        self.assertEqual(t('μs'), float('2.33e6'))
        self.assertEqual(t('ns'), float('2.33e9'))
        self.assertEqual(t('ps'), float('2.33e12'))
        self.assertEqual(t('fs'), float('2.33e15'))
        self.assertEqual(t('as'), float('2.33e18'))
Exemple #4
0
    def test_time_zero(self):
        t = quantity.Time(0.0, 's')

        self.assertEqual(t('ms'), float('0'))
        self.assertEqual(t('μs'), float('0'))
        self.assertEqual(t('ns'), float('0'))
        self.assertEqual(t('ps'), float('0'))
        self.assertEqual(t('fs'), float('0'))
        self.assertEqual(t('as'), float('0'))
Exemple #5
0
    def test_acceleration_from_l_t(self):
        l = quantity.Length(1, "m")
        t = quantity.Time(1, "s")
        a1 = l / (t * t)
        a2 = l / (t**2)
        a3 = l / t / t

        self.assertIsInstance(a1, quantity.Acceleration)
        self.assertIsInstance(a2, quantity.Acceleration)
        self.assertIsInstance(a3, quantity.Acceleration)
Exemple #6
0
    def test_acceleration_from_l_t_none_zero(self):
        l = quantity.Length(2.33, "m")
        t = quantity.Time(2.33, "s")
        a1 = l / (t * t)
        a2 = l / (t**2)
        a3 = l / t / t

        self.assertAlmostEqual(a1('m s-2'), float('0.4229'), delta=1e-2)
        self.assertAlmostEqual(a2('m s-2'), float('0.4229'), delta=1e-2)
        self.assertAlmostEqual(a3('m s-2'), float('0.4229'), delta=1e-2)
Exemple #7
0
    def test_volumetricflow_233(self):
        l = quantity.Length(2.33, 'm')
        v = quantity.Volume(12.649, "m3")
        l1 = l * l * l
        t = quantity.Time(2.33, 'h')
        vf1 = l1 / t
        vf2 = v / t
        self.assertIsInstance(vf1, quantity.VolumetricFlow)
        self.assertAlmostEqual(vf1('m3 h-1'), float('5.4289'), delta=1e-6)

        self.assertIsInstance(vf2, quantity.VolumetricFlow)
        self.assertAlmostEqual(vf2('m3 h-1'), float('5.4289'), delta=1e-3)
Exemple #8
0
    def test_volumetricflow_(self):
        l = quantity.Length(1, 'm')
        v1 = l * l * l
        v2 = l**3
        t = quantity.Time(1, 'h')
        vf1 = v1 / t
        vf2 = v2 / t
        vf3 = l * l * l / t
        self.assertIsInstance(vf1, quantity.VolumetricFlow)
        self.assertEqual(vf1('m3 h-1'), float('1.'))

        self.assertIsInstance(vf2, quantity.VolumetricFlow)
        self.assertEqual(vf2('m3 h-1'), float('1.'))

        self.assertIsInstance(vf3, quantity.VolumetricFlow)
        self.assertEqual(vf3('m3 h-1'), float('1.'))
Exemple #9
0
 def test_time_from_s_to_d(self):
     t = quantity.Time(43200, "s")
     self.assertEqual(t('d'), float('0.5'))
Exemple #10
0
 def test_volumetricflow_zero(self):
     v = quantity.Volume(0, 'm3')
     t = quantity.Time(1, 'h')
     vf = v / t
     self.assertIsInstance(vf, quantity.VolumetricFlow)
     self.assertEqual(vf('m3 h-1'), float('0.'))
Exemple #11
0
 def test_time_from_min_to_s(self):
     t = quantity.Time(1.0, "min")
     self.assertEqual(t('s'), float('60'))
Exemple #12
0
 def test_time_from_s_to_min(self):
     t = quantity.Time(30, "s")
     self.assertEqual(t('min'), float('0.5'))
Exemple #13
0
 def test_time_from_hour_to_s(self):
     t = quantity.Time(1.0, "h")
     self.assertEqual(t('s'), float('3600'))
Exemple #14
0
 def test_time_from_hour_to_day(self):
     t = quantity.Time(48, "h")
     self.assertEqual(t('d'), float("2"))
Exemple #15
0
 def test_time_from_day_to_hour(self):
     t = quantity.Time(1, "d")
     self.assertEqual(t('h'), float("24"))
Exemple #16
0
 def test_time_from_s_to_hour(self):
     t = quantity.Time(3600, "s")
     self.assertEqual(t('h'), float('1'))
Exemple #17
0
 def test_time_from_d_to_s(self):
     t = quantity.Time(1.0, "d")
     self.assertEqual(t('s'), float('86400.'))