Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Oct 14, 2021
1 parent 49bca2e commit bee1f09
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/pyhf/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,14 @@ def _nominal_and_modifiers_from_spec(modifier_set, config, spec, batch_size):
moddict[f"{x['type']}/{x['name']}"] = x
helper.setdefault(c['name'], {})[s['name']] = (s, moddict)



#1. setupp nominal & modifier builders
# 1. setupp nominal & modifier builders
nominal = _nominal_builder(config)

modifiers_builders = {}
for k, (builder, applier) in modifier_set.items():
modifiers_builders[k] = builder(config)

#2. walk spec and call builders
# 2. walk spec and call builders
for c in config.channels:
for s in config.samples:
helper_data = helper.get(c, {}).get(s)
Expand All @@ -137,13 +135,13 @@ def _nominal_and_modifiers_from_spec(modifier_set, config, spec, batch_size):
thismod = defined_mods.get(key) if defined_mods else None
modifiers_builders[mtype].append(key, c, s, thismod, defined_samp)

#3. finalize nominal & modifierr builders
# 3. finalize nominal & modifierr builders
nominal_rates = nominal.finalize()
finalizd_builder_data = {}
for k, (builder, applier) in modifier_set.items():
finalizd_builder_data[k] = modifiers_builders[k].finalize()

#4. collect parameters from spec annd from user .. at this point we know all constraints and so forth
# 4. collect parameters from spec annd from user .. at this point we know all constraints and so forth
_required_paramsets = {}
for v in list(modifiers_builders.values()):
for pname, req_list in v.required_parsets.items():
Expand All @@ -152,29 +150,33 @@ def _nominal_and_modifiers_from_spec(modifier_set, config, spec, batch_size):

user_parameters = spec.get('parameters', [])

_required_paramsets = _finalize_parameters_specs(user_parameters,_required_paramsets,)
_prameter_objects, _auxdata, _auxdata_order = _create_parameters_from_spec(_required_paramsets)
_required_paramsets = _finalize_parameters_specs(
user_parameters,
_required_paramsets,
)
_prameter_objects, _auxdata, _auxdata_order = _create_parameters_from_spec(
_required_paramsets
)

if not _required_paramsets:
raise exceptions.InvalidModel('No parameters specified for the Model.')

config.set_parameters(_prameter_objects)
config.set_auxinfo(_auxdata, _auxdata_order)
#6. use finnaliized modifier data to build reparametization fuction for main lhood part

# 6. use finnaliized modifier data to build reparametization fuction for main lhood part
the_modifiers = {}
for k, (builder, applier) in modifier_set.items():
the_modifiers[k] = applier(
modifiers=[
x for x in config.modifiers if x[1] == k
], # filter modifier names for that mtype (x[1])
pdfconfig=config,
builder_data=finalizd_builder_data.get(k) ,
builder_data=finalizd_builder_data.get(k),
batch_size=batch_size,
**config.modifier_settings.get(k, {}),
)


return the_modifiers, nominal_rates


Expand Down

0 comments on commit bee1f09

Please sign in to comment.