def _validate_with_metadata(self, obj, name, value, src_units):
        """Perform validation and unit conversion using metadata from
        the source trait.
        """

        # pylint: disable=E1101
        dst_units = self.units

        if isinstance(value, UncertainDistribution):
            value = value.getvalue()

        # FIXME: The try blocks testing whether the unit is bogus or undefined
        # are generally redundant because that test is done at creation. HOWEVER
        # you might have a case where it wasn't tested because it's technically
        # not a float. NPSS wrapper may be such a case. A test needs to be
        # constructed to test these lines.

        try:
            pq = PhysicalQuantity(value, src_units)
        except NameError:
            raise NameError("while setting value of %s: undefined unit '%s'" %
                             (src_units, name))

        try:
            pq.convert_to_unit(dst_units)
        except __HOLE__:
            raise NameError("undefined unit '%s' for variable '%s'" %
                             (dst_units, name))
        except TypeError:
            msg = "%s: units '%s' are incompatible " % (name, src_units) + \
                   "with assigning units of '%s'" % (dst_units)
            raise TypeError(msg)

        return pq.value
dataset/ETHPy150Open OpenMDAO/OpenMDAO-Framework/openmdao.main/src/openmdao/main/datatypes/float.py/Float._validate_with_metadata