CompositeUnit

class astropy.units.core.CompositeUnit(scale, bases, powers) [edit on github][source]

Bases: astropy.units.core.UnitBase

Create a composite unit using expressions of previously defined units.

Direct use of this class is not recommended. Instead use the factory function Unit(...) and arithmetic operators to compose units.

Parameters :

scale : number

A scaling factor for the unit.

bases : sequence of UnitBase

A sequence of units this unit is composed of.

powers : sequence of numbers

A sequence of powers (in parallel with bases) for each of the base units.

Attributes Summary

bases Return the bases of the composite unit.
scale Return the scale of the composite unit.
powers Return the powers of the composite unit.

Methods Summary

is_dimensionless() Returns True if this unit translates into a scalar quantity without a unit.
simplify() Compresses a possibly composite unit down to a single instance.
dimensionless_constant() If this unit is dimensionless, return its scalar quantity.
decompose() Return a unit object composed of only irreducible units.

Attributes Documentation

bases[source]

Return the bases of the composite unit.

scale[source]

Return the scale of the composite unit.

powers[source]

Return the powers of the composite unit.

Methods Documentation

is_dimensionless() [edit on github][source]

Returns True if this unit translates into a scalar quantity without a unit.

Examples

>>> ((2 * u.m) / (3 * u.m)).is_dimensionless()
True
>>> (2 * u.m).is_dimensionless()
False
simplify() [edit on github][source]

Compresses a possibly composite unit down to a single instance.

dimensionless_constant() [edit on github][source]

If this unit is dimensionless, return its scalar quantity.

Direct use of this method is not recommended. It is generally better to use the to or get_converter methods instead.

decompose() [edit on github][source]

Return a unit object composed of only irreducible units.

Parameters :

None :

Returns :

unit : CompositeUnit object

New object containing only irreducible unit objects.

Page Contents