Bases: object
Abstract base class for units.
Most of the arithmetic operations on units are defined in this base class.
Should not be instantiated by users directly.
Attributes Summary
physical_type | Return the physical type on the unit. |
Methods Summary
compose([equivalencies, units, max_depth, ...]) | Return the simplest possible composite unit(s) that represent the given unit. |
decompose([bases]) | Return a unit object composed of only irreducible units. |
find_equivalent_units([equivalencies, ...]) | Return a list of all the units that are the same type as the specified unit. |
get_converter(other[, equivalencies]) | Return the conversion function to convert values from self to the specified unit. |
in_units(other[, value, equivalencies]) | Alias for to for backward compatibility with pynbody. |
is_equivalent(other[, equivalencies]) | Returns True if this unit is equivalent to other. |
to(other[, value, equivalencies]) | Return the converted values in the specified unit. |
to_string([format]) | Output the unit in the given format as a string. |
to_system(system) | Converts this unit into ones belonging to the given system. |
Attributes Documentation
Return the physical type on the unit.
Examples
>>> u.m.physical_type
'length'
Methods Documentation
Return the simplest possible composite unit(s) that represent the given unit. Since there may be multiple equally simple compositions of the unit, a list of units is always returned.
Parameters : | equivalencies : list of equivalence pairs, optional
units : set of units to compose to, optional
max_depth : int, optional
include_prefix_units : bool, optional
|
---|---|
Returns : | units : list of CompositeUnit
|
Return a unit object composed of only irreducible units.
Parameters : | bases : sequence of UnitBase, optional
|
---|---|
Returns : | unit : CompositeUnit object
|
Return a list of all the units that are the same type as the specified unit.
Parameters : | u : Unit instance or string
equivalencies : list of equivalence pairs, optional
units : set of units to search in, optional
include_prefix_units : bool, optional
|
---|---|
Returns : | units : list of UnitBase
|
Return the conversion function to convert values from self to the specified unit.
Parameters : | other : unit object or string
equivalencies : list of equivalence pairs, optional
|
---|---|
Returns : | func : callable
|
Raises : | UnitsException :
|
Alias for to for backward compatibility with pynbody.
Returns True if this unit is equivalent to other.
Parameters : | other : unit object or string
equivalencies : list of equivalence pairs, optional
|
---|---|
Returns : | bool : |
Return the converted values in the specified unit.
Parameters : | other : unit object or string
value : scalar int or float, or sequence that can be converted to array, optional
equivalencies : list of equivalence pairs, optional
|
---|---|
Returns : | values : scalar or array
|
Raises : | UnitException :
|
Output the unit in the given format as a string.
Parameters : | format : astropy.format.Base instance or str
|
---|
Converts this unit into ones belonging to the given system. Since more than one result may be possible, a list is always returned.
Parameters : | system : module
|
---|---|
Returns : | units : list of CompositeUnit
|