Reference
Validators for the configuration options.
We can combine multiple validation conditions by summing them, thus creating a AND condition
Raises: InvalidConfiguration: If passed value does not meet its imposed conditions InternalError: Passing unknown configuration of the methods
constraint_map = {'ValueInInterval': ValueInInterval, 'ValueFromDtype': ValueFromDtype, 'IterableMustHave': IterableMustHave, 'ValueFromList': ValueFromIterable}
module-attribute
Positive_Value_Constraint = ValueInInterval((0, np.inf), include_edges=True)
module-attribute
StringValue = ValueFromDtype((str,))
module-attribute
PathValue = ValueFromDtype((str, Path)) + PathExists()
module-attribute
NumericValue = ValueFromDtype((int, float))
module-attribute
IntegerValue = ValueFromDtype((int,))
module-attribute
BooleanValue = ValueFromDtype((bool,))
module-attribute
predefined_constraints = {'Positive_Value_Constraint': Positive_Value_Constraint, 'StringValue': StringValue, 'PathValue': PathValue, 'NumericValue': NumericValue, 'IntegerValue': IntegerValue, 'BooleanValue': BooleanValue}
module-attribute
Constraint
Base class to define a constraint on possible values that a parameter can take.
Serves as parent class, allows the "sum" of two constraints to make "AND" operations
Attributes: constraint_text: String that describes the constraint
Raises: InvalidConfiguration: If the constraint on the parameter value is not met
Source code in src/ASTRA/utils/parameter_validators.py
constraint_text = const_text
instance-attribute
check_if_value_meets_constraint(value: Any) -> None
Compare the provided value against all constraint.
Args: value (Any): Value to be compared
Raises: InvalidConfiguration: If the value is not met
Source code in src/ASTRA/utils/parameter_validators.py
ValueInInterval
Bases: Constraint
Constraint that imposes the provided value to be inside a given interval.
Source code in src/ASTRA/utils/parameter_validators.py
ValueFromDtype
Bases: Constraint
Constraint that limits the datatype of the input.
Source code in src/ASTRA/utils/parameter_validators.py
valid_dtypes = dtype_list
instance-attribute
ValueFromIterable
Bases: Constraint
Limits the possible values to be inside a list.
Source code in src/ASTRA/utils/parameter_validators.py
available_options = available_options
instance-attribute
IterableMustHave
Bases: Constraint
Imposes that certain values must be inside a given iterable.
Source code in src/ASTRA/utils/parameter_validators.py
available_options = available_options
instance-attribute
mode = mode
instance-attribute
PathExists
Bases: Constraint
Imposes that a given path must exist.