Utils
Utility functions to validate user inputs.
- lasersafety.utils.validate_wavelength_en207(wavelength: float | int) None
Check that the wavelength is compatible with the EN207 standard.
- Parameters:
wavelength (Union[float, int]) – the wavelength to validate, in m.
- Raises:
ValueError – if the wavelength is not a float or an int.
ValueError – if the wavelength is outside the range 180 nm - 1 mm.
- lasersafety.utils.validate_wavelength_en208(wavelength: float | int) None
Check that the wavelength is compatible with the EN208 standard.
- Parameters:
wavelength (Union[float, int]) – the wavelength to validate, in m.
- Raises:
ValueError – if the wavelength is not a float or an int.
ValueError – if the wavelength is outside the range 400 nm - 700 nm.
- lasersafety.utils.validate_strictly_positive_number(number: float | int, parameter_name='parameter') None
Check that the input number is stritcly positive.
- Parameters:
number (Union[float, int]) – the number to validate.
parameter_name (str, optional) – the parameter, for raising exceptions. Defaults to “parameter”.
- Raises:
ValueError – if the number is not a float or an int.
ValueError – if the number is lower or equal to 0.
- lasersafety.utils.format_value(value: float | int) str
Format a scientific value with scientific prefixes.
It is compatible with prefixes from femto to Giga.
- Parameters:
value (float | int) – the value to format.
- Raises:
ValueError – if the input value is not a float or an int.
- Returns:
the formatted scientific value.
- Return type:
str