eradiate.validators
#
- eradiate.validators.all_positive(_, attribute, value)[source]#
Validate iff value is a vector with all its values positive.
- Raises:
ValueError – If not all values are positive.
- eradiate.validators.all_strictly_positive(_, attribute, value)[source]#
Validate iff value is a vector with all its values strictly positive.
- Raises:
ValueError – If not all values are strictly positive.
- eradiate.validators.auto_or(*wrapped_validators)[source]#
Allow for an attribute to be set to
AUTO
.- Parameters:
*wrapped_validators (
callable()
) – Validators to be applied to values not equal toAUTO
.
- eradiate.validators.has_len(size)[source]#
Validate iff value is a vector with specified length.
- Parameters:
size (
int
) – Expected size of the validated value.- Raises:
ValueError – If the value does not have the expected size.
- eradiate.validators.has_quantity(quantity)[source]#
Validate iff initializer is called with a value featuring a
quantity
field set to an expected value.- Parameters:
quantity (
PhysicalQuantity
orstr
orNone
) – Expected quantity field.- Raises:
ValueError – If the value’s
quantity
field does not match the expected value.
- eradiate.validators.is_dir(_, attribute, value)[source]#
Validate iff initializer is called with a value defining a path to an existing directory.
- Raises:
FileNotFoundError – If the value is not a
pathlib.Path
which points to an existing directory.
- eradiate.validators.is_file(_, attribute, value)[source]#
Validate iff initializer is called with a value defining a path to an existing file.
- Raises:
FileNotFoundError – If the value is not a
pathlib.Path
which points to an existing file.
- eradiate.validators.is_number(_, attribute, value)[source]#
Validate iff value is of a numeric type.
- Raises:
TypeError – If the value is not a
Number
.
- eradiate.validators.is_positive(_, attribute, value)[source]#
Validate iff value is a positive number.
- Raises:
ValueError – If the value is not positive or zero.
- eradiate.validators.is_scalar(_, attribute, value)[source]#
Validate iff value is of scalar type in the sense of Numpy.
- Raises:
TypeError – If the value is not scalar.
- eradiate.validators.is_vector3(instance, attribute, value)[source]#
Validate iff value can be converted to a (3,) Numpy array.
- Raises:
TypeError – If value cannot be converted to a (3,)
numpy.ndarray
.
- eradiate.validators.on_quantity(wrapped_validator)[source]#
Apply a validator to the magnitude of a quantity.
- Parameters:
wrapped_validator (
callable()
) – The validator applied to the value’s magnitude.
- eradiate.validators.path_exists(_, attribute, value)[source]#
Validate iff initializer is called with a value defining a path to an existing location.
- Raises:
FileNotFoundError – If the value is not a
pathlib.Path
which points to an existing location.
- eradiate.validators.validate_absorption_data(instance, attribute, value)[source]#
Validate absorption data.
- Raises:
TypeError – If the value is not a dict with keys of type tuple and length 2, and values of type
xarray.Dataset
.