Console#
- class astropy.units.format.Console(*args, **kwargs)[source]#
Bases:
BaseOutput-only format for to display pretty formatting at the console.
For example:
>>> import astropy.units as u >>> print(u.Ry.decompose().to_string('console')) 2.1798721*10^-18 m^2 kg s^-2 >>> print(u.Ry.decompose().to_string('console', fraction='multiline')) m^2 kg 2.1798721*10^-18 ------ s^2 >>> print(u.Ry.decompose().to_string('console', fraction='inline')) 2.1798721*10^-18 m^2 kg / s^2
Attributes Summary
Methods Summary
to_string(unit[, fraction, deprecations])Convert a unit to its string representation.
Attributes Documentation
- name = 'console'#
Methods Documentation
- classmethod to_string(unit, fraction=False, deprecations=DeprecatedUnitAction.WARN)[source]#
Convert a unit to its string representation.
Implementation for
to_string.- Parameters:
- unit|Unit|
The unit to convert.
- deprecations{“warn”, “silent”, “raise”, “convert”}, optional, keyword-only
Whether deprecated units should emit a warning, be handled silently or raise an error. The “convert” option replaces the deprecated unit if possible and emits a warning otherwise.
- fraction{False|True|’inline’|’multiline’}, optional
Options are as follows:
False: display unit bases with negative powers as they are (e.g.,km s-1);‘inline’ or
True: use a single-line fraction (e.g.,km / s);‘multiline’ : use a multiline fraction if possible (available for the
latex,consoleandunicodeformats; e.g.,$\mathrm{\frac{km}{s}}$). If not possible, use ‘inline’.
- Raises:
ValueErrorIf
fractionis not recognized.