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

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

        try:
            pq.convert_to_unit(dst_units)
        except NameError:
            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)

        value *= pq.value

        return value
dataset/ETHPy150Open OpenMDAO/OpenMDAO-Framework/openmdao.main/src/openmdao/main/datatypes/array.py/Array._validate_with_metadata