diff --git a/src/pyhf/mixins.py b/src/pyhf/mixins.py index 4df1f0db23..c390626748 100644 --- a/src/pyhf/mixins.py +++ b/src/pyhf/mixins.py @@ -106,7 +106,7 @@ def _check_for_duplicates(self, channels: Sequence[Channel]) -> None: duplicates = sorted( set([f"'{x}'" for x in channel_names if channel_names.count(x) > 1]) ) - raise exceptions.InvalidNameReuse( + raise exceptions.InvalidModel( "Duplicate channels " + ", ".join(duplicates) + " found in the model. Rename one of them." @@ -117,7 +117,7 @@ def _check_for_duplicates(self, channels: Sequence[Channel]) -> None: duplicates = sorted( set([f"'{x}'" for x in sample_names if sample_names.count(x) > 1]) ) - raise exceptions.InvalidNameReuse( + raise exceptions.InvalidModel( "Duplicate samples " + ", ".join(duplicates) + f" found in the channel '{channel['name']}'. Rename one of them." @@ -131,7 +131,7 @@ def _check_for_duplicates(self, channels: Sequence[Channel]) -> None: duplicates = sorted( set([f"'{x[0]}'" for x in modifiers if modifiers.count(x) > 1]) ) - raise exceptions.InvalidNameReuse( + raise exceptions.InvalidModel( "Duplicate modifiers " + ", ".join(duplicates) + f" of the same type found in channel '{channel['name']}' and sample '{sample['name']}'. Rename one of them." diff --git a/tests/test_schema.py b/tests/test_schema.py index d609966edc..a6a8a1c699 100644 --- a/tests/test_schema.py +++ b/tests/test_schema.py @@ -727,5 +727,5 @@ def test_schema_tensor_type_disallowed(mocker, backend): def test_schema_catch_duplicates(datadir, model_file): with open(datadir.joinpath(model_file), encoding="utf-8") as spec_file: model_spec = json.load(spec_file) - with pytest.raises(pyhf.exceptions.InvalidNameReuse): + with pytest.raises(pyhf.exceptions.InvalidModel): pyhf.Model(model_spec)