Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_initialize_units(self):
plonk.Units()
plonk.Units(1.0, 1.0, 1.0)
plonk.Units('cm', 'g', 's')
plonk.Units(momentum=1.0, E=1.0)
self.assertRaises(ValueError, plonk.Units, non_existent_unit=1.0)
self.assertRaises(ValueError, plonk.Units, length='non_existent_length')
def test_unit_conversion(self):
units = plonk.Units('au', 'g', 's')
au = units.convert_quantity_to_cgs(1.0, 'L')
self.assertEqual(au, 1.496e13)
units = plonk.Units('au', 'g', 'yr')
au_per_year = units.convert_quantity_to_cgs(1.0, 'L T^-1')
self.assertEqual(au_per_year, 474063.91864657536)
def test_initialize_units(self):
plonk.Units()
plonk.Units(1.0, 1.0, 1.0)
plonk.Units('cm', 'g', 's')
plonk.Units(momentum=1.0, E=1.0)
self.assertRaises(ValueError, plonk.Units, non_existent_unit=1.0)
self.assertRaises(ValueError, plonk.Units, length='non_existent_length')
def test_initialize_units(self):
plonk.Units()
plonk.Units(1.0, 1.0, 1.0)
plonk.Units('cm', 'g', 's')
plonk.Units(momentum=1.0, E=1.0)
self.assertRaises(ValueError, plonk.Units, non_existent_unit=1.0)
self.assertRaises(ValueError, plonk.Units, length='non_existent_length')
def test_initialize_units(self):
plonk.Units()
plonk.Units(1.0, 1.0, 1.0)
plonk.Units('cm', 'g', 's')
plonk.Units(momentum=1.0, E=1.0)
self.assertRaises(ValueError, plonk.Units, non_existent_unit=1.0)
self.assertRaises(ValueError, plonk.Units, length='non_existent_length')
def test_unit_conversion(self):
units = plonk.Units('au', 'g', 's')
au = units.convert_quantity_to_cgs(1.0, 'L')
self.assertEqual(au, 1.496e13)
units = plonk.Units('au', 'g', 'yr')
au_per_year = units.convert_quantity_to_cgs(1.0, 'L T^-1')
self.assertEqual(au_per_year, 474063.91864657536)