コード例 #1
0
ファイル: test_parmed_unit.py プロジェクト: zyguostx/ParmEd
 def testIsUnit(self):
     """ Tests the unit.is_unit introspective function """
     self.assertTrue(u.is_unit(u.meters))
     self.assertFalse(u.is_unit(None))
     self.assertFalse(u.is_unit(10))
     # Distinguish between "units" and "quantities"
     self.assertFalse(u.is_unit(1 * u.meters))
コード例 #2
0
ファイル: test_parmed_unit.py プロジェクト: rmcgibbo/ParmEd
 def testIsUnit(self):
     """ Tests the unit.is_unit introspective function """
     self.assertTrue(u.is_unit(u.meters))
     self.assertFalse(u.is_unit(None))
     self.assertFalse(u.is_unit(10))
     # Distinguish between "units" and "quantities"
     self.assertFalse(u.is_unit(1*u.meters))
コード例 #3
0
ファイル: test_parmed_unit.py プロジェクト: zyguostx/ParmEd
 def testUnitDivision(self):
     """ Tests the division of units and is_dimensionless """
     mps = u.meter / u.second
     mpm = u.meter / u.meter
     mpc = u.meter / u.centimeter
     self.assertTrue(u.is_unit(mps))
     self.assertTrue(u.is_unit(mpm))
     self.assertTrue(u.is_unit(mpc))
     self.assertFalse(mps.is_dimensionless())
     self.assertTrue(mpm.is_dimensionless())
     self.assertTrue(mpc.is_dimensionless())
コード例 #4
0
ファイル: test_parmed_unit.py プロジェクト: zyguostx/ParmEd
 def testCreateNewUnit(self):
     """ Tests creating a new Unit """
     ms = u.milli * u.second
     self.assertTrue(u.is_unit(ms))
     self.assertEqual(
         repr(ms), 'Unit({BaseUnit(base_dim=BaseDimension("time"), '
         'name="millisecond", symbol="ms"): 1.0})')
コード例 #5
0
ファイル: test_parmed_unit.py プロジェクト: zyguostx/ParmEd
 def testCreateNewScaledUnit(self):
     """ Tests creating a new ScaledUnit """
     mC = u.milli * u.ScaledUnit(4.184, u.joule, "calorie", "cal")
     self.assertIsInstance(mC, u.ScaledUnit)
     self.assertEqual(
         repr(mC),
         "ScaledUnit(factor=0.004184, master=joule, name='millicalorie',"
         " symbol='mcal')")
     self.assertFalse(u.is_unit(mC))
コード例 #6
0
ファイル: test_parmed_unit.py プロジェクト: zyguostx/ParmEd
 def testCompositeUnits(self):
     """ Tests the creation of a composite unit """
     mps = u.Unit({u.meter_base_unit: 1.0, u.second_base_unit: -1.0})
     self.assertTrue(u.is_unit(mps))
     self.assertEqual(str(mps), 'meter/second')
コード例 #7
0
ファイル: test_parmed_unit.py プロジェクト: zyguostx/ParmEd
 def testBaseScaleMix(self):
     """ Test mixing of BaseUnit and ScaledUnit instances """
     kgj = u.kilogram * u.joule
     self.assertTrue(u.is_unit(kgj))
     self.assertEqual(str(kgj.sqrt()), 'kilogram*meter/second')
コード例 #8
0
ファイル: vec3.py プロジェクト: xy21hb/ParmEd
 def __rmul__(self, other):
     """Multiply a Vec3 by a constant."""
     if unit.is_unit(other):
         return unit.Quantity(self, other)
     return Vec3(other * self[0], other * self[1], other * self[2])