parmed.unit.Unit

class parmed.unit.Unit(base_or_scaled_units)[source]

Physical unit such as meter or ampere.

Methods

conversion_factor_to(other)

Returns conversion factor for computing all of the common dimensions between self and other from self base units to other base units.

create_unit(scale, name, symbol)

Convenience method for creating a new simple unit from another simple unit.

get_conversion_factor_to_base_units()

There may be ScaleUnit components to this Unit.

get_name()

Returns a unit name (string) for this Unit, composed of its various BaseUnit symbols.

get_symbol()

Returns a unit symbol (string) for this Unit, composed of its various BaseUnit symbols.

in_unit_system(system)

Returns a new Unit with the same dimensions as this one, expressed in a particular unit system.

is_compatible(other)

Returns True if two Units share the same dimension.

is_dimensionless()

Returns True if this Unit has no dimensions.

iter_all_base_units()

Yields (BaseUnit, exponent) tuples comprising this unit, including those BaseUnits found within ScaledUnits.

iter_base_dimensions()

Yields (BaseDimension, exponent) tuples comprising this unit.

iter_top_base_units()

Yields (BaseUnit, exponent) tuples in this Unit, excluding those within BaseUnits.

sqrt()

Returns square root of a unit.

iter_base_or_scaled_units

iter_scaled_units

__init__(base_or_scaled_units)[source]

Create a new Unit.

Parameters:
  • self (Unit) The newly created Unit.

  • base_or_scaled_units (dict) Keys are BaseUnits or ScaledUnits. Values are exponents (numbers).

Methods

__init__(base_or_scaled_units)

Create a new Unit.

conversion_factor_to(other)

Returns conversion factor for computing all of the common dimensions between self and other from self base units to other base units.

create_unit(scale, name, symbol)

Convenience method for creating a new simple unit from another simple unit.

get_conversion_factor_to_base_units()

There may be ScaleUnit components to this Unit.

get_name()

Returns a unit name (string) for this Unit, composed of its various BaseUnit symbols.

get_symbol()

Returns a unit symbol (string) for this Unit, composed of its various BaseUnit symbols.

in_unit_system(system)

Returns a new Unit with the same dimensions as this one, expressed in a particular unit system.

is_compatible(other)

Returns True if two Units share the same dimension.

is_dimensionless()

Returns True if this Unit has no dimensions.

iter_all_base_units()

Yields (BaseUnit, exponent) tuples comprising this unit, including those BaseUnits found within ScaledUnits.

iter_base_dimensions()

Yields (BaseDimension, exponent) tuples comprising this unit.

iter_base_or_scaled_units()

iter_scaled_units()

iter_top_base_units()

Yields (BaseUnit, exponent) tuples in this Unit, excluding those within BaseUnits.

sqrt()

Returns square root of a unit.