Skip to content

Commit

Permalink
use InvalidModel instead of InvalidNameReuse, due to failing of other…
Browse files Browse the repository at this point in the history
… tests
  • Loading branch information
lorenzennio committed Dec 8, 2023
1 parent e6887d9 commit edea8ef
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/pyhf/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand All @@ -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."
Expand All @@ -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."
Expand Down
2 changes: 1 addition & 1 deletion tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit edea8ef

Please sign in to comment.