Conversion to base unit.
 Returns the quantity converted to a base unit.
 @return [Phys::Quantity] a quantity in the base unit.
 @raise  [Phys::UnitError] if unit conversion is failed.
764566
def to_base_unit
      unit = @unit.base_unit
      val  = unit.convert(self)
      expr = unit.unit_string
      self.class.new( val, expr, unit )
    end
653237
def analog_units(self):
        
        au = []
        us = []
        for each in self.points:
            if isinstance(each, NumericPoint):
                au.append(each.properties.name)
                us.append(each.properties.units_state)
        return dict(zip(au, us))
865660
def units(self):
        
        existing = [i.units for i in self.geometry.values()]

        if any(existing[0] != e for e in existing):
            # if all of our geometry doesn't have the same units already
            # this function will only do some hot nonsense
            raise ValueError('models in scene have inconsistent units!')

        return existing[0]
1325531
def to_unit(self, unit):
        """"""
        new_data_c = self.duplicate()
        new_data_c.convert_to_unit(unit)
        return new_data_c
872469
def to_s(mode = nil)
      unit_string = unit.to_s(mode)
      if unit_string && unit_string != '1'
        "#{simplified_value} #{unit_string}"
      else
        simplified_value.to_s
      end
    end
1107080
def to_base
      return self if base?
      if @@unit_map[units] =~ /\A<(?:temp|deg)[CRF]>\Z/
        @signature = @@kinds.key(:temperature)
        base = if temperature?
                 convert_to('tempK')
               elsif degree?
                 convert_to('degK')
               end
        return base
      end

      cached = (begin
                  (@@base_unit_cache[units] * scalar)
                rescue
                  nil
                end)
      return cached if cached

      num = []
      den = []
      q   = Rational(1)
      @numerator.compact.each do |num_unit|
        if @@prefix_values[num_unit]
          q *= @@prefix_values[num_unit]
        else
          q *= @@unit_values[num_unit][:scalar] if @@unit_values[num_unit]
          num << @@unit_values[num_unit][:numerator] if @@unit_values[num_unit] && @@unit_values[num_unit][:numerator]
          den << @@unit_values[num_unit][:denominator] if @@unit_values[num_unit] && @@unit_values[num_unit][:denominator]
        end
      end
      @denominator.compact.each do |num_unit|
        if @@prefix_values[num_unit]
          q /= @@prefix_values[num_unit]
        else
          q /= @@unit_values[num_unit][:scalar] if @@unit_values[num_unit]
          den << @@unit_values[num_unit][:numerator] if @@unit_values[num_unit] && @@unit_values[num_unit][:numerator]
          num << @@unit_values[num_unit][:denominator] if @@unit_values[num_unit] && @@unit_values[num_unit][:denominator]
        end
      end

      num = num.flatten.compact
      den = den.flatten.compact
      num = UNITY_ARRAY if num.empty?
      base = RubyUnits::Unit.new(RubyUnits::Unit.eliminate_terms(q, num, den))
      @@base_unit_cache[units] = base
      base * @scalar
    end
1224087
def to_si
      if @unit.is_compound_unit?
        Quantity.new(@value,@unit).convert_compound_unit_to_si!
      elsif @unit.is_dimensionless?
        return self.clone
      elsif @value.nil?
        return Quantity.new(nil, @unit.si_unit)
      else
        self.to(@unit.si_unit)
      end
    end
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
484294
def get_amount_in_base_currency(self, currency: str, amount: Decimal) -> Decimal:
        
        assert isinstance(amount, Decimal)

        # If this is already the base currency, do nothing.
        if currency == self.get_default_currency().mnemonic:
            return amount

        agg = self.get_currency_aggregate_by_symbol(currency)
        if not agg:
            raise ValueError(f"Currency not found: {currency}!")

        # TODO use pricedb for the price.
        rate_to_base = agg.get_latest_price()
        if not rate_to_base:
            raise ValueError(f"Latest price not found for {currency}!")
        assert isinstance(rate_to_base.value, Decimal)

        result = amount * rate_to_base.value
        return result
1016890
def get_total_mass(self):
        
        try:
            mass = self.loc[:, 'mass'].sum()
        except KeyError:
            mass_molecule = self.add_data('mass')
            mass = mass_molecule.loc[:, 'mass'].sum()
        return mass
1362056
def to_a
      if dimension == 0
        force
      else
        n = shape.last
        ( 0 ... n ).collect { |i| element( i ).to_a }
      end
    end
25099
def unit(self, parameter):
        ""
        parameter = self._get_parameter_name(parameter).lower()
        return self._parameters[parameter]['Unit']
604972
def dimension
      q = nil
      u = self.base.si_units
      SI_UNITS.each_pair do |dim, unit|
        unit = Measure.new(1.0, unit) unless unit.kind_of?(Measure)
        if unit.base.si_units == u
          q = dim
          break
        end
      end
      q
    end
512767
def wave(self, wavelength):
        
        # Test units
        if not isinstance(wavelength, q.quantity.Quantity):
            raise ValueError("Wavelength must be in length units.")

        self._wave = wavelength
        self.wave_units = wavelength.unit
1028208
def _convert_units(self):
        
        self.m1 = self.m1*M_sun*ct.G/ct.c**2
        self.m2 = self.m2*M_sun*ct.G/ct.c**2
        initial_cond_type_conversion = {
            'time': ct.c*ct.Julian_year,
            'frequency': 1./ct.c,
            'separation': ct.parsec,
        }

        self.initial_point = self.initial_point*initial_cond_type_conversion[self.initial_cond_type]

        self.t_obs = self.t_obs*ct.c*ct.Julian_year
        return
346756
def add_or_subtract!(operator,other)
      if other.is_a? Quantity
        other = other.to(@unit) if other.unit.is_alternative_for?(@unit)

        if @unit.is_equivalent_to? other.unit
          @value = @value.send operator, other.value

          return self
        else
          raise Quantify::Exceptions::InvalidObjectError, "Cannot add or subtract Quantities with different dimensions"
        end
      else
        raise Quantify::Exceptions::InvalidObjectError, "Cannot add or subtract non-Quantity objects"
      end
    end
171040
function () {
            var ret = [],
                quantities = Array.prototype.slice.call(arguments);

            if (quantities.length === 1) {
                return quantities[0];
            }

            if (quantities.length > 0) {
                var baseQuantity = quantities[0];

                for (var i = 0; i < baseQuantity.length; i++) {
                    var item = baseQuantity[i],
                        found = true;

                    for (var j = 1; j < quantities.length; j++) {
                        if (!_.contains(quantities[j], item)) {
                            found = false;
                            break;
                        }
                    }

                    if (found) {
                        ret.push(item);
                    }
                }
            }


            return ret;
        }