ParameterGroup

class glotaran.parameter.parameter_group.ParameterGroup() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list.  For example:  dict(one=1, two=2)[source]

Bases: dict

Represents are group of parameters. Can contain other groups, creating a tree-like hierarchy.

Parameters

label – The label of the group.

Attributes Summary

label

Label of the group.

root_group

Root of the group.

Methods Summary

add_group

Adds a ParameterGroup to the group.

add_parameter

Adds a Parameter to the group.

all

Returns a generator over all parameter in the group and it’s subgroups together with their labels.

clear

copy

from_csv

Creates a ParameterGroup from a CSV file.

from_dataframe

Creates a ParameterGroup from a pandas.DataFrame

from_dict

Creates a ParameterGroup from a dictionary.

from_file

from_list

Creates a ParameterGroup from a list.

from_yaml

Creates a ParameterGroup from a YAML string.

from_yaml_file

Creates a ParameterGroup from a YAML file.

fromkeys

Create a new dictionary with keys from iterable and values set to value.

get

Gets a Parameter by its label.

get_label_value_and_bounds_arrays

Returns a arrays of all parameter labels, values and bounds.

get_nr_roots

Returns the number of roots of the group.

groups

Returns a generator over all groups and their subgroups.

has

Checks if a parameter with the given label is in the group or in a subgroup.

items

keys

known_formats

markdown

Formats the ParameterGroup as markdown string.

pop

If key is not found, d is returned if given, otherwise KeyError is raised

popitem

Remove and return a (key, value) pair as a 2-tuple.

set_from_label_and_value_arrays

Updates the parameter values from a list of labels and values.

setdefault

Insert key with a value of default if key is not in the dictionary.

to_csv

Writes a ParameterGroup to a CSV file.

to_dataframe

update

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

update_parameter_expression

Updates all parameters which have an expression.

values

Methods Documentation

add_group(group: glotaran.parameter.parameter_group.ParameterGroup)[source]

Adds a ParameterGroup to the group.

Parameters

group – The group to add.

add_parameter(parameter: Parameter | list[Parameter])[source]

Adds a Parameter to the group.

Parameters

parameter – The parameter to add.

all(root: str = None, separator: str = '.')Generator[tuple[str, Parameter], None, None][source]

Returns a generator over all parameter in the group and it’s subgroups together with their labels.

Parameters
  • root – The label of the root group

  • separator – The separator for the parameter labels.

clear()None.  Remove all items from D.
copy()a shallow copy of D[source]
classmethod from_csv(filepath: str, delimiter: Optional[str] = None)glotaran.parameter.parameter_group.ParameterGroup[source]

Creates a ParameterGroup from a CSV file.

Parameters
  • filepath – The path to the CSV file.

  • delimiter – The delimiter of the CSV file.

classmethod from_dataframe(df: pandas.core.frame.DataFrame, source: str = 'DataFrame')glotaran.parameter.parameter_group.ParameterGroup[source]

Creates a ParameterGroup from a pandas.DataFrame

classmethod from_dict(parameter_dict: dict[str, dict | list], label: str = None, root_group: ParameterGroup = None)ParameterGroup[source]

Creates a ParameterGroup from a dictionary.

Parameters
  • parameter_dict – A parameter dictionary containing parameters.

  • label – The label of root group.

  • root_group – The root group

classmethod from_file(filepath: str, fmt: Optional[str] = None)[source]
classmethod from_list(parameter_list: list[float | list], label: str = None, root_group: ParameterGroup = None)ParameterGroup[source]

Creates a ParameterGroup from a list.

Parameters
  • parameter_list – A parameter list containing parameters

  • label – The label of the root group.

  • root_group – The root group

classmethod from_yaml(yaml_string: str)glotaran.parameter.parameter_group.ParameterGroup[source]

Creates a ParameterGroup from a YAML string.

Parameters

yaml_string – The YAML string with the parameters.

classmethod from_yaml_file(filepath: str)glotaran.parameter.parameter_group.ParameterGroup[source]

Creates a ParameterGroup from a YAML file.

Parameters

filepath – The path to the YAML file.

fromkeys(iterable, value=None, /)

Create a new dictionary with keys from iterable and values set to value.

get(label: str)glotaran.parameter.parameter.Parameter[source]

Gets a Parameter by its label.

Parameters

label – The label of the parameter.

get_label_value_and_bounds_arrays(exclude_non_vary: bool = False)tuple[list[str], np.ndarray, np.ndarray, np.ndarray][source]

Returns a arrays of all parameter labels, values and bounds.

Parameters

exclude_non_vary (bool = False) – If true, parameters with vary=False are excluded.

get_nr_roots()int[source]

Returns the number of roots of the group.

groups()Generator[glotaran.parameter.parameter_group.ParameterGroup, None, None][source]

Returns a generator over all groups and their subgroups.

has(label: str)bool[source]

Checks if a parameter with the given label is in the group or in a subgroup.

Parameters

label – The label of the parameter.

items()a set-like object providing a view on D’s items
keys()a set-like object providing a view on D’s keys
classmethod known_formats()dict[str, Callable][source]
property label

Label of the group.

markdown()str[source]

Formats the ParameterGroup as markdown string.

pop(k[, d])v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised

popitem(/)

Remove and return a (key, value) pair as a 2-tuple.

Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.

property root_group

Root of the group.

set_from_label_and_value_arrays(labels: list[str], values: np.ndarray)[source]

Updates the parameter values from a list of labels and values.

setdefault(key, default=None, /)

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

to_csv(filename: str, delimiter: str = ',')[source]

Writes a ParameterGroup to a CSV file.

Parameters
  • filepath – The path to the CSV file.

  • delimiter (str) – The delimiter of the CSV file.

to_dataframe()pandas.core.frame.DataFrame[source]
update([E, ]**F)None.  Update D from dict/iterable E and F.

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

update_parameter_expression()[source]

Updates all parameters which have an expression.

values()an object providing a view on D’s values