calix.common.boundary_check

Classes

BoundaryCheckResult(parameters, error_mask, …)

Result object for boundary checks. Contains: * Parameters clipped to a desired parameter range. * Boolean mask of parameters which initially exceeded the desired parameter range. Values of True indicate reaching the boundaries. * List of strings containing error messages. May be empty, as messages are only returned if errors are given.

Functions

calix.common.boundary_check.check_range_boundaries(parameters: np.ndarray, boundaries: ParameterRange, errors: Optional[List[str]] = None)BoundaryCheckResult

Checks if parameters are in a given range and sets them to the limits if they exceed the range. If error messages are given, returns those if a parameter has reached the limits or has gone beyond.

Parameters
  • parameters – Array of parameters to check.

  • boundaries – Parameter range to be checked for.

  • errors – List of error messages to print when parameter exceeds respective boundaries, in format [err_lower, err_upper]. Message needs to include placeholer ‘{0}’ where indices of the violating parameters are inserted.

Returns

BoundaryCheckResult, containing parameters within boundaries, error mask and optional error messages.

calix.common.boundary_check.dataclass(cls=None, /, *, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False)

Returns the same class as was passed in, with dunder methods added based on the fields defined in the class.

Examines PEP 526 __annotations__ to determine fields.

If init is true, an __init__() method is added to the class. If repr is true, a __repr__() method is added. If order is true, rich comparison dunder methods are added. If unsafe_hash is true, a __hash__() method function is added. If frozen is true, fields may not be assigned to after instance creation.