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 of the group.
Root of the group.
Methods Summary
Adds a
ParameterGroup
to the group.Adds a
Parameter
to the group.Returns a generator over all parameter in the group and it’s subgroups together with their labels.
Creates a
ParameterGroup
from a CSV file.Creates a
ParameterGroup
from apandas.DataFrame
Creates a
ParameterGroup
from a dictionary.Creates a
ParameterGroup
from a list.Creates a
ParameterGroup
from a YAML string.Creates a
ParameterGroup
from a YAML file.Create a new dictionary with keys from iterable and values set to value.
Gets a
Parameter
by its label.Returns a arrays of all parameter labels, values and bounds.
Returns the number of roots of the group.
Returns a generator over all groups and their subgroups.
Checks if a parameter with the given label is in the group or in a subgroup.
Formats the
ParameterGroup
as markdown string.If key is not found, d is returned if given, otherwise KeyError is raised
Remove and return a (key, value) pair as a 2-tuple.
Updates the parameter values from a list of labels and values.
Insert key with a value of default if key is not in the dictionary.
Writes a
ParameterGroup
to a CSV file.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]
Updates all parameters which have an expression.
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.¶
-
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 apandas.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_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.
-
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¶
-
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.
-
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]
-
values
() → an object providing a view on D’s values¶