spines.parameters.factories

Parameter factory functions

spines.parameters.factories.bound_mixin(name, checker, cls_name=None)[source]

Creates a new mixin class for bounded parameters

This factory function makes creating bound mixins very simple, you only need to provide the name for the attribute on the resulting class for this particular boundary condition, and provide a callable checker to perform the validation. The checker call needs to look like this:

The call should return True when the value is within the boundary and False when it’s not. The checker doesn’t necessarily have to be a function, it just needs to be callable.

Parameters
  • name (str) – Name of the property holding the bound’s value.

  • checker (callable) – Callable object/function to assess the boundary condition.

  • cls_name (str, optional) – Name for the newly created class type (defaults to name + ‘BoundMixin’).

Returns

New parameter mixin class for the bound specified.

Return type

ParameterMixin

Raises

ValueError – If the given checker is not callable.