set_enabled_equivalencies

astropy.units.set_enabled_equivalencies(equivalencies)[source] [edit on github]

Sets the equivalencies enabled in the unit registry.

These equivalencies are used if no explicit equivalencies are given, both in unit conversion and in finding equivalent units.

This is meant in particular for allowing angles to be dimensionless. Use with care.

Parameters:

equivalencies : list of equivalent pairs

E.g., as returned by dimensionless_angles.

Examples

Exponentiation normally requires dimensionless quantities. To avoid problems with complex phases:

>>> from astropy import units as u
>>> with u.set_enabled_equivalencies(u.dimensionless_angles()):
...     phase = 0.5 * u.cycle
...     np.exp(1j*phase)  
<Quantity  -1. +1.22464680e-16j>