Parameter

class glotaran.parameter.parameter.Parameter(label: str = None, full_label: str = None, expression: str | None = None, maximum: float = inf, minimum: float = - inf, non_negative: bool = False, standard_error: float = nan, value: float = nan, vary: bool = True)[source]

Bases: numpy.typing._array_like._SupportsArray

A parameter for optimization.

Optimization Parameter supporting numpy array operations.

Parameters
  • label (str) – The label of the parameter., by default None

  • full_label (str) – The label of the parameter with its path in a parameter group prepended. , by default None

  • expression (str | None) – Expression to calculate the parameters value from, e.g. if used in relation to another parameter. , by default None

  • maximum (float) – Upper boundary for the parameter to be varied to., by default np.inf

  • minimum (float) – Lower boundary for the parameter to be varied to., by default -np.inf

  • non_negative (bool) – Whether the parameter should always be bigger than zero., by default False

  • standard_error (float) – The standard error of the parameter. , by default np.nan

  • value (float) – Value of the parameter, by default np.nan

  • vary (bool) – Whether the parameter should be changed during optimization or not. , by default True

Attributes Summary

expression

Expression to calculate the parameters value from.

full_label

Label of the parameter with its path in a parameter group prepended.

label

Label of the parameter.

maximum

Upper bound of the parameter.

minimum

Lower bound of the parameter.

non_negative

Indicate if the parameter is non-negative.

standard_error

Standard error of the optimized parameter.

transformed_expression

Expression of the parameter transformed for evaluation within a ParameterGroup.

value

Value of the parameter.

vary

Indicate if the parameter should be optimized.

Methods Summary

as_dict

Create a dictionary containing the parameter properties.

from_dict

Create a Parameter from a dictionary.

from_list_or_value

Create a parameter from a list or numeric value.

get_value_and_bounds_for_optimization

Get the parameter value and bounds with expression and non-negative constraints applied.

markdown

Get a markdown representation of the parameter.

set_from_group

Set all values of the parameter to the values of the corresponding parameter in the group.

set_value_from_optimization

Set the value from an optimization result and reverses non-negative transformation.

valid_label

Check if a label is a valid label for Parameter.

Methods Documentation

as_dict(as_optimized: bool = True) dict[str, Any][source]

Create a dictionary containing the parameter properties.

property expression: str | None

Expression to calculate the parameters value from.

This can used to set a relation to another parameter.

Returns

The expression.

Return type

str | None

classmethod from_dict(parameter_dict: dict[str, Any]) Parameter[source]

Create a Parameter from a dictionary.

Expects a dictionary created by :method:`Parameter.as_dict`.

Parameters

parameter_dict (dict[str, Any]) – The source dictionary.

Returns

The created Parameter

Return type

Parameter

classmethod from_list_or_value(value: int | float | list, default_options: dict = None, label: str = None) Parameter[source]

Create a parameter from a list or numeric value.

Parameters
  • value (int | float | list) – The list or numeric value.

  • default_options (dict) – A dictionary of default options.

  • label (str) – The label of the parameter.

Returns

The created Parameter.

Return type

Parameter

property full_label: str

Label of the parameter with its path in a parameter group prepended.

Returns

The full label.

Return type

str

get_value_and_bounds_for_optimization() tuple[float, float, float][source]

Get the parameter value and bounds with expression and non-negative constraints applied.

Returns

A tuple containing the value, the lower and the upper bound.

Return type

tuple[float, float, float]

property label: str | None

Label of the parameter.

Returns

The label.

Return type

str

markdown(all_parameters: ParameterGroup | None = None, initial_parameters: ParameterGroup | None = None) MarkdownStr[source]

Get a markdown representation of the parameter.

Parameters
  • all_parameters (ParameterGroup | None) – A parameter group containing the whole parameter set (used for expression lookup).

  • initial_parameters (ParameterGroup | None) – The initial parameter.

Returns

The parameter as markdown string.

Return type

MarkdownStr

property maximum: float

Upper bound of the parameter.

Returns

The upper bound of the parameter.

Return type

float

property minimum: float

Lower bound of the parameter.

Returns

The lower bound of the parameter.

Return type

float

property non_negative: bool

Indicate if the parameter is non-negative.

If true, the parameter will be transformed with p' = \log{p} and p = \exp{p'}.

Notes

Always False if expression is not None.

Returns

Whether the parameter is non-negative.

Return type

bool

set_from_group(group: ParameterGroup)[source]

Set all values of the parameter to the values of the corresponding parameter in the group.

Notes

For internal use.

Parameters

group (ParameterGroup) – The glotaran.parameter.ParameterGroup.

set_value_from_optimization(value: float)[source]

Set the value from an optimization result and reverses non-negative transformation.

Parameters

value (float) – Value from optimization.

property standard_error: float

Standard error of the optimized parameter.

Returns

The standard error of the parameter.

Return type

float

property transformed_expression: str | None

Expression of the parameter transformed for evaluation within a ParameterGroup.

Returns

The transformed expression.

Return type

str | None

static valid_label(label: str) bool[source]

Check if a label is a valid label for Parameter.

Parameters

label (str) – The label to validate.

Returns

Whether the label is valid.

Return type

bool

property value: float

Value of the parameter.

Returns

The value of the parameter.

Return type

float

property vary: bool

Indicate if the parameter should be optimized.

Notes

Always False if expression is not None.

Returns

Whether the parameter should be optimized.

Return type

bool