File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2123,14 +2123,11 @@ def split_by_model(self) -> dict[str, Problem]:
21232123 See https://github.com/PEtab-dev/libpetab-python/issues/392.
21242124
21252125 :returns: The single-model problems, keyed by model ID.
2126- :raises ValueError: If model IDs are not unique, or if any
2127- measurement is not assigned to a model.
2126+ :raises ValueError: If any measurement is not assigned to a model.
21282127 """
21292128 from ..v2 .lint import get_valid_parameters_for_parameter_table
21302129
21312130 model_ids = {model .model_id for model in self .models }
2132- if len (model_ids ) != len (self .models ):
2133- raise ValueError ("Model IDs must be unique." )
21342131
21352132 def get_model_id (measurement : Measurement ) -> str | None :
21362133 # with a single model, the model ID is optional
Original file line number Diff line number Diff line change @@ -1049,12 +1049,6 @@ def test_split_by_model():
10491049 with pytest .raises (ValueError , match = "not assigned" ):
10501050 problem .split_by_model ()
10511051
1052- # duplicate model IDs
1053- problem = _two_model_problem ()
1054- problem .models [1 ].model_id = "model_A"
1055- with pytest .raises (ValueError , match = "unique" ):
1056- problem .split_by_model ()
1057-
10581052
10591053def test_split_by_model_single_model ():
10601054 """With one model, measurements don't need a model ID."""
@@ -1087,7 +1081,15 @@ def test_validate_multi_model():
10871081 assert result .has_errors ()
10881082 assert "does not have a model ID" in result [0 ].message
10891083
1084+ # duplicate model IDs
1085+ problem = _two_model_problem ()
1086+ problem .models [1 ].model_id = "model_A"
1087+ result = problem .validate ()
1088+ assert result .has_errors ()
1089+ assert "Duplicate model IDs" in result [0 ].message
1090+
10901091 # unknown model ID
1092+ problem = _two_model_problem ()
10911093 problem .measurements [0 ].model_id = "model_C"
10921094 result = problem .validate ()
10931095 assert result .has_errors ()
You can’t perform that action at this time.
0 commit comments