Return True if a Unit representing the string units1 can be converted
    to a Unit representing the string units2, else False.

    :param str units1: A string representing the units
    :param str units2: A string representing the units
320842
def units_convertible(units1, units2, reftimeistime=True):
    
    try:
        u1 = Unit(units1)
        u2 = Unit(units2)
    except ValueError:
        return False
    return u1.is_convertible(u2)
6688
def unit_str
      rv = @numerator_units.sort.join("*")
      if @denominator_units.any?
        rv << "/"
        rv << @denominator_units.sort.join("*")
      end
      rv
    end
967263
def conversions(self):
        
        return "\n".join(str(self.to(unit)) for unit in self.supported_units)
413331
def convert_units_to_base_units(units):
    
    total_factor = 1
    new_units = []
    for unit in units:
        if unit not in BASE_UNIT_CONVERSIONS:
            continue

        factor, new_unit = BASE_UNIT_CONVERSIONS[unit]
        total_factor *= factor
        new_units.append(new_unit)

    new_units.sort()
    return total_factor, tuple(new_units)
805107
def _get_wx_units(self, params, name):
        
        units = ""
        for param in params:
            if str(name) == str(param['name']):
                units = param['units']
        return units
638110
def _parse_unit(unit, placement_str):
    
    if not unit:
        return None
    try:
        return int(unit)
    except (TypeError, ValueError):
        msg = 'unit in placement {} must be digit'.format(placement_str)
        raise ValueError(msg.encode('utf-8'))
866339
def convert_to(other)
      return self if other.nil?

      case other
        when Unit
          return self if other == self
          target = other
        when String
          target = SIUnits::Unit.new(other.to_f)
        else
          raise ArgumentError, "Unknown target units"
      end
    end
428731
def as_unit(self, unit, location='suffix', *args, **kwargs):
        
        f = Formatter(
            as_unit(unit, location=location),
            args,
            kwargs
        )
        return self._add_formatter(f)
604514
def _convert_units(devices):
    '''
    
    '''
    if devices:
        for device in devices:
            if 'unit' in device and 'size' in device:
                device.update(
                    salt.utils.vmware.convert_to_kb(device['unit'], device['size']))
    else:
        return False
    return True
136590
def to_base_units(self):
        
        # Convert to "standard" units, as defined by the conversions dict above
        amount = self.value

        numer_factor, numer_units = convert_units_to_base_units(self.unit_numer)
        denom_factor, denom_units = convert_units_to_base_units(self.unit_denom)

        return Number(
            amount * numer_factor / denom_factor,
            unit_numer=numer_units,
            unit_denom=denom_units,
        )
1297249
def unit(self, unit):
        
        allowed_values = ["cm", "inch", "foot"]  # noqa: E501
        if unit is not None and unit not in allowed_values:
            raise ValueError(
                "Invalid value for `unit` ({0}), must be one of {1}"  # noqa: E501
                .format(unit, allowed_values)
            )

        self._unit = unit
450249
def method_missing(*args)
      if Conversions.conversions[units.to_sym][args.first]
        to_f.send(units.to_sym).to(args.first)
      else
        super
      end
    end
373141
def _check_unit(new_unit, old_unit):
    

    try:

        new_unit.physical_type

    except AttributeError:

        raise UnitMismatch("The provided unit (%s) has no physical type. Was expecting a unit for %s"
                           % (new_unit, old_unit.physical_type))

    if new_unit.physical_type != old_unit.physical_type:

        raise UnitMismatch("Physical type mismatch: you provided a unit for %s instead of a unit for %s"
                           % (new_unit.physical_type, old_unit.physical_type))
1295095
def as_base_units(self):
        
        b = collections.defaultdict(int)
        factor = 1
        for k, v in self.items():
            derived = False
            for d in DERIVED_UNITS.values():
                if k in d:
                    for k2, v2 in d[k].items():
                        if isinstance(k2, Number):
                            factor *= k2 ** (v2 * v)
                        else:
                            b[k2] += v2 * v
                    derived = True
                    break
            if not derived:
                si, f = _get_si_unit(k)
                b[si] += v
                factor *= f ** v
        return {k: v for k, v in b.items() if v != 0}, factor
366261
def p_unit(self, p):
        
        unit = TimexLexer.reserved_words[p[1]]
        unit = unit.lower()
        p[0] = unit
1261991
def from_string(cls, s):
        
        # Extract num and unit string.
        s = s.strip()
        for i, char in enumerate(s):
            if char.isalpha() or char.isspace():
                break
        else:
            raise Exception("Unit is missing in string %s" % s)
        num, unit = float(s[:i]), s[i:]

        # Find unit type (set it to None if it cannot be detected)
        for unit_type, d in BASE_UNITS.items():
            if unit in d:
                break
        else:
            unit_type = None

        return cls(num, unit, unit_type=unit_type)
334254
def units(self):
        
        self._units, value = self.get_attr_string(self._units, 'units')
        return value