check_relativistic

plasmapy.utils.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:
Warns:

~plasmapy.utils.RelativityWarning – If V is greater than or equal to betafrac 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