Conversion where self is a compound unit, and new unit is not an alternative
 to the whole compound but IS an alternative to one or more of the base units,
 e.g.,

   Unit.kilowatt_hour.to :second           #=> 'kilowatt second'
161032
def convert_compound_unit_to_non_equivalent_unit!(new_unit)
      @unit.base_units.select do |base|
        base.unit.is_alternative_for? new_unit
      end.inject(self) do |quantity,base|
        factor = Unit.ratio(new_unit**base.index, base.unit**base.index)
        quantity.multiply!(factor).cancel_base_units!(base.unit)
      end
    end
1228218
def *(x)
      x = Unit.cast(x)
      if scalar?
        return x
      elsif x.scalar?
        return self.dup
      end
      check_operable2(x)
      dims = dimension_binop(x){|a,b| a+b}
      factor = self.factor * x.factor
      Unit.new(factor,dims)
    end
320842
def units_convertible(units1, units2, reftimeistime=True):
    
    try:
        u1 = Unit(units1)
        u2 = Unit(units2)
    except ValueError:
        return False
    return u1.is_convertible(u2)
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,
        )
25099
def unit(self, parameter):
        ""
        parameter = self._get_parameter_name(parameter).lower()
        return self._parameters[parameter]['Unit']
1240689
function (op, other) {
        return new(tree.Dimension)
                  (tree.operate(op, this.value, other.value),
                  this.unit || other.unit);
    }
16671
@Override
  public UnitValue convert(UnitValue value) {
    Unit src = value.unit();
    switch (src.category()) {
      case CONCENTR:
      case LIGHT:
        // Not available
        break;
        
      case ACCELERATION:
        return convert(value, Unit.METER_PER_SECOND_SQUARED, UnitFactors.ACCELERATION);
      case ANGLE:
        return convert(value, UnitFactorSets.ANGLE);
      case AREA:
        return convert(value, areaFactors());
      case CONSUMPTION:
        return convert(value, consumptionUnit());
      case DIGITAL:
        return convert(value, UnitFactorSets.DIGITAL_BYTES);
      case DURATION:
        return convert(value, UnitFactorSets.DURATION);
      case ELECTRIC:
        return convert(value, UnitFactorSets.ELECTRIC);
      case ENERGY:
        return convert(value, energyFactors());
      case FREQUENCY:
        return convert(value, UnitFactorSets.FREQUENCY);
      case LENGTH:
        return convert(value, lengthFactors());
      case MASS:
        return convert(value, massFactors());
      case POWER:
        return convert(value, UnitFactorSets.POWER);
      case PRESSURE:
        return convert(value, Unit.MILLIBAR);
      case SPEED:
        return convert(value, speedUnit());
      case TEMPERATURE:
        return convert(value, temperatureUnit());
      case VOLUME:
        return convert(value, volumeFactors());
    }
    
    return value;
  }
899164
def to_unit_cell(self, in_place=False):
        
        frac_coords = np.mod(self.frac_coords, 1)
        if in_place:
            self.frac_coords = frac_coords
        else:
            return PeriodicSite(self.species, frac_coords, self.lattice,
                                properties=self.properties)
1233807
def _to_unit_base(self, base_unit, values, unit, from_unit):
        """"""
        self._is_numeric(values)
        namespace = {'self': self, 'values': values}
        if not from_unit == base_unit:
            self.is_unit_acceptable(from_unit, True)
            statement = '[self._{}_to_{}(val) for val in values]'.format(
                self._clean(from_unit), self._clean(base_unit))
            values = eval(statement, namespace)
            namespace['values'] = values
        if not unit == base_unit:
            self.is_unit_acceptable(unit, True)
            statement = '[self._{}_to_{}(val) for val in values]'.format(
                self._clean(base_unit), self._clean(unit))
            values = eval(statement, namespace)
        return values
847081
def to_native_units(self, motor):
        
        assert abs(self.degrees_per_second) <= motor.max_dps,\
            "invalid degrees-per-second: {} max DPS is {}, {} was requested".format(
            motor, motor.max_dps, self.degrees_per_second)
        return self.degrees_per_second/motor.max_dps * motor.max_speed
227126
def **(other)
      case other
      when Integer
        if other > 0
          num = @numerator**other
          den = @denominator**other
          self.class.new(num, den)
        elsif other < 0
          num = @denominator**-other
          den = @numerator**-other
          self.class.new(num, den)
        elsif other.zero?
          unity
        end
      else
        x, y = other.coerce(self)
        x**y
      end
    end
715176
def convert(quantity)
      if Quantity===quantity
        assert_same_dimension(quantity.unit)
        v = quantity.unit.convert_value_to_base_unit(quantity.value)
        convert_value_from_base_unit(v)
      else
        quantity / to_numeric
      end
    end
207754
def unit(self, value):
        

        if isinstance(value, TimeUnit):
            self._unit = value
        else:
            self._unit = TimeUnit(value)
1257358
def convert(quantity, unit)
      return quantity if unit == self
      # if there is a converter to the target unit, then call it
      converter = @converters[unit]
      return converter.call(quantity) if converter
      # validate the target unit dimension
      unless @dimension == unit.dimension then
        raise MeasurementError.new("Cannot convert #{unit} dimension #{unit.dimension} to #{self} dimension #{@dimension}")
      end
      # convert via an axis pivot intermediary
      pivot = conversion_pivot(unit)
      pivot.as(self.as(quantity, pivot), unit)
    end
378525
def *(other)
      raise ArgumentError, "Invalid argument given" unless other.is_a?(RGB)
      rgb = compound_by(other.rgb) { |a, b| [(a*b/255.0).round, 0].max }
      self.class.new *rgb
    end
1173736
def convert(self, value, fromunits, tounits):
        ''''''
        if fromunits == tounits:
            return value
        if (fromunits,tounits) in self.unitmap:
            return value * self.unitmap[(fromunits,tounits)]
        if (tounits,fromunits) in self.unitmap:
            return value / self.unitmap[(tounits,fromunits)]
        raise fgFDMError("unknown unit mapping (%s,%s)" % (fromunits, tounits))
600003
def convert(cls, value, from_unit, to_unit):
        
        value_ms = value * cls.UNITS_IN_MILLISECONDS[from_unit]
        return value_ms / cls.UNITS_IN_MILLISECONDS[to_unit]