spines.parameters¶
Parameters module for spines.
-
class
spines.parameters.Parameter(*value_type, default: Optional[Any] = None, desc: Optional[str] = None)[source]¶ Bases:
objectParameter class
- Parameters
value_type (
typeorIterableoftype) – The type(s) of values allowed for this parameter.default (object, optional) – Default value for this parameter, if any.
desc (str, optional) – Description for this parameter, if any.
-
check(value: Any) → bool[source]¶ Checks the given value for validity
Based on this particular Parameter’s settings this method checks the given value to see if it’s in-line with the specifications.
- Parameters
value – Parameter value to check validity of.
- Returns
Whether or not the value is valid for the parameter.
- Return type
bool
See also
-
default¶ Default value to use for this parameter.
- Type
object
-
desc¶ Description of this parameter.
- Type
str
-
name¶ Name of this parameter.
- Type
str
-
preprocess(value: Any) → Any[source]¶ Pre-process/massage parameter values into correct type
This is used to try and convert parameter values to the allowed types (if possible). For instance the allowed type may be a
floatbut the user provides1, we would likely not want to break in that situation, but simply convert theintgiven into afloat. However, this can also be used to perform more complex initialization or customization on given parameter values, if needed.The default method is to try and cast the given value as the types given in this Parameter’s
_value_typesattribute and returning the first successful cast, otherwise returns the given input value.This method can be easily extended or overridden for custom Parameter classes to handle more complex value types.
- Parameters
value (object) – The value to pre-process for this parameter.
- Returns
The pre-processed value.
- Return type
object
Note
This method is, by default, only called if the given value fails this Parameter’s
checkcall.See also
-
required¶ Whether or not this parameter is required to be set.
- Type
bool
-
value_type¶ The types of values allowed for this option.
- Type
tuple
-
class
spines.parameters.HyperParameter(*value_type, default: Optional[Any] = None, desc: Optional[str] = None)[source]¶ Bases:
spines.parameters.base.ParameterHyper-parameter
-
class
spines.parameters.Bounded(*args, **kwargs)[source]¶ Bases:
spines.parameters.mixins.Minimum,spines.parameters.mixins.Maximum,spines.parameters.base.ParameterBounded parameter (min/max)
-
class
spines.parameters.HyperBounded(*args, **kwargs)[source]¶ Bases:
spines.parameters.mixins.Minimum,spines.parameters.mixins.Maximum,spines.parameters.base.HyperParameterBounded hyper-parameter (min/max)
-
class
spines.parameters.ParameterStore[source]¶ Bases:
collections.abc.MutableMappingHelper class for managing collections of Parameters.
-
add(parameter: Type[spines.parameters.base.Parameter]) → None[source]¶ Add a
Parameterspecification to this store
-
copy(deep: bool = False) → Type[spines.parameters.store.ParameterStore][source]¶ Returns a copy of this parameter store object.
- Parameters
deep (bool, optional) – Whether or not to do deep-copying of this stores contents.
- Returns
Copied parameter store object.
- Return type
-
final¶ Whethor or not this set of parameters is finalized.
- Type
bool
-
finalize() → None[source]¶ Finalizes the parameters stored
- Raises
MissingParameterException – If a required parameter is not set.
-
parameters¶ Copy of the current set of parameters.
- Type
dict
-
valid¶ Whether or not this is a fully valid set of parameters.
- Type
bool
-
values¶ Copy of the current set of parameter values.
- Type
dict
-
-
exception
spines.parameters.InvalidParameterException[source]¶ Bases:
spines.parameters.base.ParameterExceptionThrown when an invalid parameter is given.
-
exception
spines.parameters.MissingParameterException[source]¶ Bases:
spines.parameters.base.ParameterExceptionThrown when a required parameter is missing.