NamedUnit¶
-
class
astropy.units.NamedUnit(st, doc=None, format=None, namespace=None)[source]¶ Bases:
astropy.units.UnitBaseThe base class of units that have a name.
Parameters: - st : str, list of str, 2-tuple
The name of the unit. If a list of strings, the first element is the canonical (short) name, and the rest of the elements are aliases. If a tuple of lists, the first element is a list of short names, and the second element is a list of long names; all but the first short name are considered “aliases”. Each name should be a valid Python identifier to make it easy to access, but this is not required.
- namespace : dict, optional
When provided, inject the unit, and all of its aliases, in the given namespace dictionary. If a unit by the same name is already in the namespace, a ValueError is raised.
- doc : str, optional
A docstring describing the unit.
- format : dict, optional
A mapping to format-specific representations of this unit. For example, for the
Ohmunit, it might be nice to have it displayed as\Omegaby thelatexformatter. In that case,formatargument should be set to:{'latex': r'\Omega'}
Raises: - ValueError
If any of the given unit names are already in the registry.
- ValueError
If any of the given unit names are not valid Python tokens.
Attributes Summary
aliasesReturns the alias (long) names for this unit. long_namesReturns all of the long names associated with this unit. nameReturns the canonical (short) name associated with this unit. namesReturns all of the names associated with this unit. short_namesReturns all of the short names associated with this unit. Methods Summary
get_format_name(format)Get a name for this unit that is specific to a particular format. Attributes Documentation
-
aliases¶ Returns the alias (long) names for this unit.
-
long_names¶ Returns all of the long names associated with this unit.
-
name¶ Returns the canonical (short) name associated with this unit.
-
names¶ Returns all of the names associated with this unit.
-
short_names¶ Returns all of the short names associated with this unit.
Methods Documentation