Skip to content

Commit

Permalink
fix: more robust param types fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
andrzejnovak committed Jul 11, 2022
1 parent 9a1346e commit dc642b7
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/cabinetry/model_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import json
import logging
import re
from typing import Any, Dict, List, NamedTuple, Optional, Tuple, Union

import awkward as ak
Expand Down Expand Up @@ -522,10 +521,16 @@ def _labels_modifiers(
) -> Tuple[List[str], List[Optional[str]]]:
""" """
labels = model.config.par_names()
_mod_dict = dict(model.config.modifiers)
_clean_labels = [re.sub(r"\[.*\]", "", label) for label in labels]
types = [_mod_dict[n] if n in _mod_dict else None for n in _clean_labels]
return labels, types
types = []
for parameter in model.config.par_order:
types += [
[
mod_type
for par_name, mod_type in model.config.modifiers
if par_name == parameter
]
] * model.config.param_set(parameter).n_parameters
return labels, sum(types, []) # flatten types


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

0 comments on commit dc642b7

Please sign in to comment.