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
betafrac
times 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
V
is not in units of velocity.ValueError – If
V
contains anynan
values.RelativityError – If
V
is greater than or equal to the speed of light.
- Warns:
RelativityWarning
– IfV
is greater than or equal tobetafrac
times 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