Bases: astropy.units.core.NamedUnit
The main unit class.
There are a number of different ways to construct a Unit, but always returns a UnitBase instance. If the arguments refer to an already-existing unit, that existing unit instance is returned, rather than a new one.
From a string:
Unit(s, format=None, parse_strict='silent')
Construct from a string representing a (possibly compound) unit.
The optional format keyword argument specifies the format the string is in, by default "generic". For a description of the available formats, see astropy.units.format.
The optional parse_strict keyword controls what happens when an unrecognized unit string is passed in. It may be one of the following:
- 'raise': (default) raise a ValueError exception.
- 'warn': emit a Warning, and return an UnrecognizedUnit instance.
- 'silent': return an UnrecognizedUnit instance.
From a number:
Unit(number)
Creates a dimensionless unit.
From a UnitBase instance:
Unit(unit)
Returns the given unit unchanged.
From None:
Unit()
Returns the null unit.
The last form, which creates a new Unit is described in detail below.
Parameters : | st : str or list of str
represents : UnitBase instance
register : boolean, optional doc : str, optional
format : dict, optional
|
---|---|
Raises : | ValueError :
ValueError :
|
Methods Summary
decompose() | Return a unit object composed of only irreducible units. |
Methods Documentation
Return a unit object composed of only irreducible units.
Parameters : | None : |
---|---|
Returns : | unit : CompositeUnit object
|