astro py:docs

- Index
- Modules

### Navigation

- next »
- « previous |
- Astropy v5.2.1 »
- Units and Quantities (`astropy.units`) »
- CompositeUnit

# CompositeUnit

class astropy.units.CompositeUnit(scale, bases, powers, decompose=False, decompose_bases={}, _error_check=True)

  Bases: `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 python:sequence of `UnitBase`

      A sequence of units this unit is composed of.

    powers python: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.
  `powers` | Return the powers of the composite unit.
  `scale` | Return the scale of the composite unit.

  Methods Summary

  `decompose`([bases]) | Return a unit object composed of only irreducible units.
  `is_unity`() | Returns `True` if the unit is unscaled and dimensionless.

  Attributes Documentation

  bases

    Return the bases of the composite unit.

  powers

    Return the powers of the composite unit.

  scale

    Return the scale of the composite unit.

  Methods Documentation

  decompose(bases={})

    Return a unit object composed of only irreducible units.

    Parameters:
      bases python:sequence of `UnitBase`, optional

        The bases to decompose into. When not provided, decomposes down to any irreducible units. When provided, the decomposed result will only contain the given units. This will raises a `UnitsError` if it’s not possible to do so.

    Returns:
      unit `CompositeUnit`

        New object containing only irreducible unit objects.

  is_unity()

    Returns `True` if the unit is unscaled and dimensionless.