Skip to content

Commit 9b00079

Browse files
committed
fix: more robust param types fetch
1 parent 66c574b commit 9b00079

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/cabinetry/model_utils.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import json
44
import logging
5-
import re
65
from typing import Any, Dict, List, NamedTuple, Optional, Tuple, Union
76

87
import awkward as ak
@@ -522,10 +521,16 @@ def _labels_modifiers(
522521
) -> Tuple[List[str], List[Optional[str]]]:
523522
""" """
524523
labels = model.config.par_names()
525-
_mod_dict = dict(model.config.modifiers)
526-
_clean_labels = [re.sub(r"\[.*\]", "", label) for label in labels]
527-
types = [_mod_dict[n] if n in _mod_dict else None for n in _clean_labels]
528-
return labels, types
524+
types = []
525+
for parameter in model.config.par_order:
526+
types += [
527+
[
528+
mod_type
529+
for par_name, mod_type in model.config.modifiers
530+
if par_name == parameter
531+
]
532+
] * model.config.param_set(parameter).n_parameters
533+
return labels, sum(types, []) # flatten types
529534

530535

531536
def match_fit_results(model: pyhf.pdf.Model, fit_results: FitResults) -> FitResults:

0 commit comments

Comments
 (0)