Skip to content

Commit

Permalink
fix weird whitespace issues
Browse files Browse the repository at this point in the history
  • Loading branch information
adrn committed Jan 12, 2018
1 parent 0908b03 commit 2118e95
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions twobody/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,37 @@ class UnitSystem:
representations for composite units. For example, the base unit system
could be ``{kpc, Myr, Msun, radian}``, but you can also specify a preferred
speed, such as ``km/s``.
This class functions like a dictionary with keys set by physical types.
If a unit for a particular physical type is not specified on creation,
a composite unit will be created with the base units. See Examples below
for some demonstrations.
Parameters
----------
*units
The units that define the unit system. At minimum, this must
contain length, time, mass, and angle units.
Examples
--------
If only base units are specified, any physical type specified as a key
to this object will be composed out of the base units::
>>> usys = UnitSystem(u.m, u.s, u.kg, u.radian)
>>> usys['energy']
Unit("kg m2 / s2")
However, custom representations for composite units can also be specified
when initializing::
>>> usys = UnitSystem(u.m, u.s, u.kg, u.radian, u.erg)
>>> usys['energy']
Unit("erg")
This is useful for Galactic dynamics where lengths and times are usually
given in terms of ``kpc`` and ``Myr``, but speeds are given in ``km/s``::
>>> usys = UnitSystem(u.kpc, u.Myr, u.Msun, u.radian, u.km/u.s)
>>> usys['speed']
Unit("km / s")
Expand Down Expand Up @@ -126,10 +134,12 @@ def decompose(self, q):
A thin wrapper around :meth:`astropy.units.Quantity.decompose` that
knows how to handle Quantities with physical types with non-default
representations.
Parameters
----------
q : :class:`~astropy.units.Quantity`
An instance of an astropy Quantity object.
Returns
-------
q : :class:`~astropy.units.Quantity`
Expand All @@ -149,14 +159,17 @@ def decompose(self, q):
def get_constant(self, name):
"""
Retrieve a constant with specified name in this unit system.
Parameters
----------
name : str
The name of the constant, e.g., G.
Returns
-------
const : float
The value of the constant represented in this unit system.
Examples
--------
>>> usys = UnitSystem(u.kpc, u.Myr, u.radian, u.Msun)
Expand Down

0 comments on commit 2118e95

Please sign in to comment.