4.6.13 pde.tools.parameters module
Infrastructure for managing classes with parameters.
One aim is to allow easy management of inheritance of parameters.
Class representing a single parameter. |
|
A parameter that can still be used normally but is deprecated. |
|
A helper class that allows hiding parameters of the parent classes. |
|
A mixin that manages the parameters of a class. |
|
Get a dictionary with all parameters of all registered classes. |
- class DeprecatedParameter(name, default_value=None, cls=<class 'object'>, description='', hidden=False, extra=None)[source]
Bases:
Parameter
A parameter that can still be used normally but is deprecated.
Initialize a parameter.
- Parameters:
name (str) – The name of the parameter
default_value – The default value
cls – The type of the parameter, which is used for conversion
description (str) – A string describing the impact of this parameter. This description appears in the parameter help
hidden (bool) – Whether the parameter is hidden in the description summary
extra (dict) – Extra arguments that are stored with the parameter
- class HideParameter(name)[source]
Bases:
object
A helper class that allows hiding parameters of the parent classes.
- Parameters:
name (str) – The name of the parameter
- class Parameter(name, default_value=None, cls=<class 'object'>, description='', hidden=False, extra=None)[source]
Bases:
object
Class representing a single parameter.
Initialize a parameter.
- Parameters:
name (str) – The name of the parameter
default_value – The default value
cls – The type of the parameter, which is used for conversion
description (str) – A string describing the impact of this parameter. This description appears in the parameter help
hidden (bool) – Whether the parameter is hidden in the description summary
extra (dict) – Extra arguments that are stored with the parameter
- convert(value=None)[source]
Converts a value into the correct type for this parameter. If value is not given, the default value is converted.
Note that this does not make a copy of the values, which could lead to unexpected effects where the default value is changed by an instance.
- Parameters:
value – The value to convert
- Returns:
The converted value, which is of type self.cls
- class Parameterized(parameters=None)[source]
Bases:
object
A mixin that manages the parameters of a class.
Initialize the parameters of the object.
- Parameters:
parameters (dict) – A dictionary of parameters to change the defaults. The allowed parameters can be obtained from
get_parameters()
or displayed by callingshow_parameters()
.
- get_parameter_default(name)[source]
Return the default value for the parameter with name
- Parameters:
name (str) – The parameter name
- classmethod get_parameters(include_hidden=False, include_deprecated=False, sort=True)[source]
Return a dictionary of parameters that the class supports.
- parameters_default: Sequence[Parameter | HideParameter] = []
- show_parameters(description=None, sort=False, show_hidden=False, show_deprecated=False)[source]
Show all parameters in human readable format.
- Parameters:
description (bool) – Flag determining whether the parameter description is shown. The default is to show the description only when we are in a jupyter notebook environment.
sort (bool) – Flag determining whether the parameters are sorted
show_hidden (bool) – Flag determining whether hidden parameters are shown
show_deprecated (bool) – Flag determining whether deprecated parameters are shown
default_value (bool) – Flag determining whether the default values or the current values are shown
All flags default to False.