Beispiel #1
0
    def get_range(self, obj=None, family_name=None, unit_system=None):
        """ Returns (left, right) tuple signifying format range for plotting
            typically. """

        from scimath.units.unit_manager import unit_manager

        # for now, assume we can get the family_name from the obj, if needed
        if family_name==None:
            family_name = obj.family_name

        # If unit_system is None, sets to default system, or looks up string
        unit_system = unit_manager.get_unit_system(unit_system)

        return self.ranges[family_name][unit_system.name.lower()]
Beispiel #2
0
    def get_range(self, obj=None, family_name=None, unit_system=None):
        """ Returns (left, right) tuple signifying format range for plotting
            typically. """

        from scimath.units.unit_manager import unit_manager

        # for now, assume we can get the family_name from the obj, if needed
        if family_name is None:
            family_name = obj.family_name

        # If unit_system is None, sets to default system, or looks up string
        unit_system = unit_manager.get_unit_system(unit_system)

        return self.ranges[family_name][unit_system.name.lower()]
Beispiel #3
0
    def test_conversion_tracks_parents(self):
        """ Test that a _converted_from traits is set appropriately.

        Quantity converted from another quantity via change_unit_system has
        the _converted_from trait set appropriately.
        """

        metric_system = unit_manager.get_unit_system("METRIC")
        metric_depth = metric_system.units("depth")

        q1 = Quantity(32, units="m", family_name="depth")
        q2 = q1.change_unit_system("IMPERIAL")
        q3 = q2.change_unit_system("METRIC")

        self.assertEqual(q1, q2._converted_from, "Conversion failed to track conversion parent.")
        self.assertEqual(q2, q3._converted_from, "Conversion failed to track conversion parent.")

        return
    def test_conversion_tracks_parents(self):
        """ Test that a _converted_from traits is set appropriately.

        Quantity converted from another quantity via change_unit_system has
        the _converted_from trait set appropriately.
        """

        metric_system = unit_manager.get_unit_system('METRIC')
        metric_depth = metric_system.units('depth')

        q1 = Quantity(32, units='m', family_name='depth')
        q2 = q1.change_unit_system('IMPERIAL')
        q3 = q2.change_unit_system('METRIC')

        self.assertEqual(q1, q2._converted_from,
                         "Conversion failed to track conversion parent.")
        self.assertEqual(q2, q3._converted_from,
                         "Conversion failed to track conversion parent.")

        return
def _get_unit_system(unit_system=None):
    from scimath.units.unit_manager import unit_manager
    return unit_manager.get_unit_system(unit_system)
Beispiel #6
0
def _get_unit_system(unit_system=None):
    from scimath.units.unit_manager import unit_manager
    return unit_manager.get_unit_system(unit_system)