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
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: TypeError– IfVis not aQuantity.UnitConversionError– IfVis not in units of velocity.ValueError– IfVcontains anynanvalues.RelativityError– IfVis greater than or equal to the speed of light.
Warns: ~plasmapy.utils.RelativityWarning – If
Vis greater than or equal tobetafractimes 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 (