Model

class glotaran.model.model.Model(*, megacomplex_types: dict[str, type[Megacomplex]], default_megacomplex_type: str | None = None, dataset_group_models: dict[str, DatasetGroupModel] = None)[source]

Bases: object

A base class for global analysis models.

Attributes Summary

dataset_group_models

default_megacomplex

The default megacomplex used by this model.

global_dimension

Deprecated use Scheme.global_dimensions['<dataset_name>'] instead

global_megacomplex

Alias for glotaran.model.megacomplex.

megacomplex_types

The megacomplex types used by this model.

model_dimension

Deprecated use Scheme.model_dimensions['<dataset_name>'] instead

model_items

The model_items types used by this model.

Methods Summary

as_dict

from_dict

Creates a model from a dictionary.

get_dataset_groups

get_parameters

is_groupable

loader

Create a Model instance from the specs defined in a file.

markdown

Formats the model as Markdown string.

need_index_dependent

Returns true if e.g.

problem_list

Returns a list with all problems in the model and missing parameters if specified.

valid

Returns True if the number problems in the model is 0, else False

validate

Returns a string listing all problems in the model and missing parameters if specified.

Methods Documentation

as_dict() dict[source]
property dataset_group_models: dict[str, DatasetGroupModel]
property default_megacomplex: str

The default megacomplex used by this model.

classmethod from_dict(model_dict: dict[str, Any], *, megacomplex_types: dict[str, type[Megacomplex]] | None = None, default_megacomplex_type: str | None = None) Model[source]

Creates a model from a dictionary.

Parameters
  • model_dict (dict[str, Any]) – Dictionary containing the model.

  • megacomplex_types (dict[str, type[Megacomplex]] | None) – Overwrite ‘megacomplex_types’ in model_dict for testing.

  • default_megacomplex_type (str | None) – Overwrite ‘default_megacomplex’ in model_dict for testing.

get_dataset_groups() dict[str, DatasetGroup][source]
get_parameters() list[str][source]
property global_dimension

Deprecated use Scheme.global_dimensions['<dataset_name>'] instead

property global_megacomplex: dict[str, Megacomplex]

Alias for glotaran.model.megacomplex. Needed internally.

is_groupable(parameters: ParameterGroup, data: dict[str, xr.DataArray]) bool[source]
loader(format_name: str = None, **kwargs: Any) Model

Create a Model instance from the specs defined in a file.

Parameters
  • file_name (StrOrPath) – File containing the model specs.

  • format_name (str) – Format the file is in, if not provided it will be inferred from the file extension.

  • **kwargs (Any) – Additional keyword arguments passes to the load_model implementation of the project io plugin.

Returns

Model instance created from the file.

Return type

Model

markdown(parameters: Optional[glotaran.parameter.parameter_group.ParameterGroup] = None, initial_parameters: Optional[glotaran.parameter.parameter_group.ParameterGroup] = None, base_heading_level: int = 1) glotaran.utils.ipython.MarkdownStr[source]

Formats the model as Markdown string.

Parameters will be included if specified.

Parameters
  • parameter (ParameterGroup) – Parameter to include.

  • initial_parameters (ParameterGroup) – Initial values for the parameters.

  • base_heading_level (int) –

    Base heading level of the markdown sections.

    E.g.:

    • If it is 1 the string will start with ‘# Model’.

    • If it is 3 the string will start with ‘### Model’.

property megacomplex_types: dict[str, type[Megacomplex]]

The megacomplex types used by this model.

property model_dimension

Deprecated use Scheme.model_dimensions['<dataset_name>'] instead

property model_items: dict[str, type[object]]

The model_items types used by this model.

need_index_dependent() bool[source]

Returns true if e.g. clp_relations with intervals are present.

problem_list(parameters: ParameterGroup = None) list[str][source]

Returns a list with all problems in the model and missing parameters if specified.

Parameters

parameter – The parameter to validate.

valid(parameters: Optional[glotaran.parameter.parameter_group.ParameterGroup] = None) bool[source]

Returns True if the number problems in the model is 0, else False

Parameters

parameter – The parameter to validate.

validate(parameters: Optional[glotaran.parameter.parameter_group.ParameterGroup] = None, raise_exception: bool = False) str[source]

Returns a string listing all problems in the model and missing parameters if specified.

Parameters

parameter – The parameter to validate.