check_relativistic¶
-
plasmapy.utils.decorators.checks.
check_relativistic
(func=None, betafrac=0.05)¶ 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: TypeError
– IfV
is not aQuantity
.UnitConversionError
– IfV
is not in units of velocity.ValueError
– IfV
contains anynan
values.RelativityError
– IfV
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
>>> from astropy import 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
- func (