File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,9 @@ def __init__(
3636 reorder
3737
3838 Raises:
39- ValueError: if the same sample is merged into multiple new samples
39+ ValueError: if a sample in the map does not exist in the model, if the
40+ same sample is merged into multiple new samples, or if a new sample
41+ name conflicts with an existing sample not included in the merge
4042 """
4143 # original values from pyhf model
4244 self .samples = model .config .samples
@@ -57,9 +59,18 @@ def __init__(
5759 ]
5860 if len (merged_samples ) != len (set (merged_samples )):
5961 raise ValueError ("each sample can only be used once" )
62+ if unknown := set (merged_samples ) - set (self .samples ):
63+ raise ValueError (
64+ f"sample(s) { unknown } not found in model, available: { self .samples } "
65+ )
6066 remaining_samples = [
6167 sample for sample in self .samples if sample not in merged_samples
6268 ]
69+ if conflict := set (self .sample_update_map .keys ()) & set (remaining_samples ):
70+ raise ValueError (
71+ f"new sample name(s) { conflict } conflict with existing samples "
72+ f"not included in the merge"
73+ )
6374 self .samples = list (self .sample_update_map .keys ()) + remaining_samples
6475
6576
You can’t perform that action at this time.
0 commit comments