model

glotaran.model.decorator.model(model_type: str, attributes: Optional[Dict[str, Any]] = None, dataset_type: Type[glotaran.model.dataset_descriptor.DatasetDescriptor] = <class 'glotaran.model.dataset_descriptor.DatasetDescriptor'>, megacomplex_type: Optional[Any] = None, matrix: Optional[Union[Callable[[Type[glotaran.model.dataset_descriptor.DatasetDescriptor], xarray.core.dataset.Dataset], Tuple[List[str], numpy.ndarray]], Callable[[Type[glotaran.model.dataset_descriptor.DatasetDescriptor], xarray.core.dataset.Dataset, Any], Tuple[List[str], numpy.ndarray]]]] = None, global_matrix: Optional[Callable[[Type[glotaran.model.dataset_descriptor.DatasetDescriptor], numpy.ndarray], Tuple[List[str], numpy.ndarray]]] = None, model_dimension: Optional[str] = None, global_dimension: Optional[str] = None, has_matrix_constraints_function: Optional[Callable[[Type[glotaran.model.base_model.Model]], bool]] = None, constrain_matrix_function: Optional[Callable[[Type[glotaran.model.base_model.Model], glotaran.parameter.parameter_group.ParameterGroup, List[str], numpy.ndarray, float], Tuple[List[str], numpy.ndarray]]] = None, retrieve_clp_function: Optional[Callable[[Type[glotaran.model.base_model.Model], glotaran.parameter.parameter_group.ParameterGroup, Dict[str, Union[List[str], List[List[str]]]], Dict[str, Union[List[str], List[List[str]]]], Dict[str, List[numpy.ndarray]], Dict[str, xarray.core.dataset.Dataset]], Dict[str, List[numpy.ndarray]]]] = None, has_additional_penalty_function: Optional[Callable[[Type[glotaran.model.base_model.Model]], bool]] = None, additional_penalty_function: Optional[Callable[[Type[glotaran.model.base_model.Model], glotaran.parameter.parameter_group.ParameterGroup, Dict[str, Union[List[str], List[List[str]]]], Dict[str, List[numpy.ndarray]], Dict[str, Union[numpy.ndarray, List[numpy.ndarray]]], Dict[str, xarray.core.dataset.Dataset], float], numpy.ndarray]] = None, finalize_data_function: Optional[Callable[[glotaran.analysis.problem.Problem, Dict[str, xarray.core.dataset.Dataset]], None]] = None, grouped: Union[bool, Callable[[Type[glotaran.model.base_model.Model]], bool]] = False, index_dependent: Union[bool, Callable[[Type[glotaran.model.base_model.Model]], bool]] = False)Callable[source]

The @model decorator is intended to be used on subclasses of glotaran.model.Model. It creates properties for the given attributes as well as functions to add access them. Also it adds the functions (e.g. for matrix) to the model ensures they are added wrapped in a correct way.

Parameters
  • model_type (str) – Human readable string used by the parser to identify the correct model.

  • attributes (Dict[str, Any], optional) – A dictionary of attribute names and types. All types must be decorated with the glotaran.model.model_attribute() decorator, by default None.

  • dataset_type (Type[DatasetDescriptor], optional) – A subclass of DatasetDescriptor, by default DatasetDescriptor

  • megacomplex_type (Any, optional) – A class for the model megacomplexes. The class must be decorated with the glotaran.model.model_attribute() decorator, by default None

  • matrix (Union[MatrixFunction, IndexDependentMatrixFunction], optional) – A function to calculate the matrix for the model, by default None

  • global_matrix (GlobalMatrixFunction, optional) – A function to calculate the global matrix for the model, by default None

  • model_dimension (str, optional) – The name of model matrix row dimension, by default None

  • global_dimension (str, optional) – The name of model global matrix row dimension, by default None

  • has_matrix_constraints_function (Callable[[Type[Model]], bool], optional) – True if the model as a constrain_matrix_function set, by default None

  • constrain_matrix_function (ConstrainMatrixFunction, optional) – A function to constrain the global matrix for the model, by default None

  • retrieve_clp_function (RetrieveClpFunction, optional) – A function to retrieve the full clp from the reduced, by default None

  • has_additional_penalty_function (Callable[[Type[Model]], bool], optional) – True if model has a additional_penalty_function set, by default None

  • additional_penalty_function (PenaltyFunction, optional) – A function to calculate additional penalties when optimizing the model, by default None

  • finalize_data_function (FinalizeFunction, optional) – A function to finalize data after optimization, by default None

  • grouped (Union[bool, Callable[[Type[Model]], bool]], optional) – True if model described a grouped problem, by default False

  • index_dependent (Union[bool, Callable[[Type[Model]], bool]], optional) – True if model described a index dependent problem, by default False

Returns

Returns a decorated model function

Return type

Callable

Raises
  • ValueError – If model implements meth:has_matrix_constraints_function but not meth:constrain_matrix_function and meth:retrieve_clp_function

  • ValueError – If model implements meth:has_additional_penalty_function but not meth:additional_penalty_function