Skip to content

Commit

Permalink
Fixed small bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
joernweissenborn committed Oct 3, 2022
1 parent ab66705 commit 23e3082
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
11 changes: 9 additions & 2 deletions glotaran/model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,19 +137,26 @@ def _load_global_items_from_dict(
return [_load_item_from_dict(item_type, value) for value in item_list]


def _add_default_dataset_group(dataset_groups: dict[str, DatasetGroupModel]):
def _load_dataset_groups(
dataset_groups: dict[str, DatasetGroupModel | Any]
) -> dict[str, DatasetGroupModel]:
"""Add the default dataset group if not present.
Parameters
----------
dataset_groups: dict[str, DatasetGroupModel]
The dataset groups.
Returns
-------
dict[str, DatasetGroupModel]
"""
dataset_group_items = _load_model_items_from_dict(DatasetGroupModel, dataset_groups)
if DEFAULT_DATASET_GROUP not in dataset_group_items:
dataset_group_items[DEFAULT_DATASET_GROUP] = DatasetGroupModel(
label=DEFAULT_DATASET_GROUP # type:ignore[call-arg]
)
return dataset_group_items # type:ignore[return-value]


def _global_item_attribute(item_type: type[Item]) -> Attribute:
Expand Down Expand Up @@ -222,7 +229,7 @@ class Model:
clp_relations: list[Relation] = _global_item_attribute(Relation)

dataset_groups: dict[str, DatasetGroupModel] = ib(
factory=dict, converter=_add_default_dataset_group, metadata=META
factory=dict, converter=_load_dataset_groups, metadata=META
)

dataset: dict[str, DatasetModel]
Expand Down
6 changes: 3 additions & 3 deletions glotaran/optimization/matrix_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from glotaran.model.dataset_model import is_dataset_model_index_dependent
from glotaran.model.dataset_model import iterate_dataset_model_global_megacomplexes
from glotaran.model.dataset_model import iterate_dataset_model_megacomplexes
from glotaran.model.interval_property import IntervalProperty
from glotaran.model.interval_item import IntervalItem
from glotaran.model.item import fill_item
from glotaran.optimization.data_provider import DataProvider
from glotaran.optimization.data_provider import DataProviderLinked
Expand Down Expand Up @@ -236,12 +236,12 @@ def combine_megacomplex_matrices(
return tmp_clp_labels, tmp_matrix

@staticmethod
def does_interval_property_apply(prop: IntervalProperty, index: int | None) -> bool:
def does_interval_property_apply(prop: IntervalItem, index: int | None) -> bool:
"""Check if an interval property applies on an index.
Parameters
----------
prop : IntervalProperty
prop : IntervalItem
The interval property.
index: int | None
The index to check.
Expand Down

0 comments on commit 23e3082

Please sign in to comment.