How to use the plonk.Units function in plonk

To help you get started, we’ve selected a few plonk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dmentipl / plonk / tests / test_units.py View on Github external
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')
github dmentipl / plonk / tests / test_units.py View on Github external
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)
github dmentipl / plonk / tests / test_units.py View on Github external
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')
github dmentipl / plonk / tests / test_units.py View on Github external
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')
github dmentipl / plonk / tests / test_units.py View on Github external
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')
github dmentipl / plonk / tests / test_units.py View on Github external
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)