spines.core.base¶
Base classes for core spines library.
-
class
spines.core.base.
BaseObject
(*args, **kwargs)[source]¶ Bases:
abc.ABC
Base object class for all spines components
-
get_params
() → Mapping[KT, VT_co][source]¶ Gets a copy of this models parameters
- Returns
Copy of currently set parameter names and values.
- Return type
dict
-
classmethod
load
(path: str, fmt: Union[None, str] = None, new: bool = False) → spines.core.base.BaseObject[source]¶ Loads an object from file
- Parameters
path (str) – Path to the file to load from.
fmt (str, optional) – Format to use when loading the file (default is
None
which will infer based on the path, if possible).new (bool, optional) – Whether or not to create a new instance from this (the calling) class or to use the stored class object (default is
False
, use the saved version).
- Returns
The new object loaded from file.
- Return type
-
parameters
¶ Parameters in this object.
- Type
-
save
(path: Union[None, str] = None, fmt: Union[None, str] = None) → str[source]¶ Saves this object to file
- Parameters
path (str, optional) – File path to save this object to.
fmt (str, optional) – Format to save this object with.
- Returns
Path to the saved object file.
- Return type
str
-
set_parameter
(name: str, value: Any) → None[source]¶ Sets a parameter value
Will add the given param and value to the parameters if they are valid, throws an exception if they are not.
- Parameters
name (str) – Parameter to set the value for.
value – Value to set.
- Raises
InvalidParameterException – If the given name or value are not valid.
See also
-
set_params
(**params) → None[source]¶ Sets the values for this model’s parameters
- Parameters
params – Parameters and values to set.
- Raises
InvalidParameterException – If the given name or value are not valid.
-
unset_parameter
(name: str) → Any[source]¶ Unsets a parameter value
Removes the specified parameter’s value from the parameter values if it is part of the parameter set and returns its current value.
- Parameters
name (str) – Name of the parameter whose value needs to be un-set.
- Returns
Previously set value of the parameter.
- Return type
object
- Raises
MissingParameterException – If the parameter to remove does not exist in the set of parameters.
See also
-