check_relativisticο
- plasmapy.utils.decorators.checks.check_relativistic(func=None, betafrac: float = 0.05)[source]ο
Warns or raises an exception when the output of the decorated function is greater than
betafractimes the speed of light.- Parameters:
func (function, optional) β The function to decorate.
betafrac (float, optional) β The minimum fraction of the speed of light that will raise a
RelativityWarning. Defaults to 5%.
- Returns:
Decorated function.
- Return type:
function
- Raises:
UnitConversionError β If
Vis not in units of velocity.ValueError β If
Vcontains anynanvalues.RelativityError β If
Vis greater than or equal to the speed of light.
- Warns:
RelativityWarningβ IfVis greater than or equal tobetafractimes the speed of light, but less than the speed of light.
Examples
>>> import astropy.units as u >>> @check_relativistic ... def speed(): ... return 1 * u.m / u.s
Passing in a custom
betafrac:>>> @check_relativistic(betafrac=0.01) ... def speed(): ... return 1 * u.m / u.s