Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Apply minor code quality revisions #1325

Merged
merged 3 commits into from
Feb 19, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/pyhf/modifiers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def wrapper(cls):
if not args:
# called like @modifier(name='foo', constrained=False, pdf_type='normal', op_code='addition')
return _modifier(name, constrained, pdf_type, op_code)
elif len(args) == 1:
if len(args) == 1:
# called like @modifier
if not callable(args[0]):
raise ValueError('You must decorate a callable python object')
Expand All @@ -158,10 +158,9 @@ def wrapper(cls):
op_code=op_code,
)
return args[0]
else:
raise ValueError(
f'@modifier must be called with only keyword arguments, @modifier(name=\'foo\'), or no arguments, @modifier; ({len(args):d} given)'
)
raise ValueError(
f'@modifier must be called with only keyword arguments, @modifier(name=\'foo\'), or no arguments, @modifier; ({len(args):d} given)'
)


from .histosys import histosys, histosys_combined
Expand Down
8 changes: 4 additions & 4 deletions src/pyhf/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,15 @@ def _nominal_and_modifiers_from_spec(config, spec):
if mtype == 'histosys':
lo_data = thismod['data']['lo_data'] if thismod else nom
hi_data = thismod['data']['hi_data'] if thismod else nom
maskval = True if thismod else False
maskval = bool(thismod)
mega_mods[key][s]['data']['lo_data'] += lo_data
mega_mods[key][s]['data']['hi_data'] += hi_data
mega_mods[key][s]['data']['nom_data'] += nom
mega_mods[key][s]['data']['mask'] += [maskval] * len(
nom
) # broadcasting
elif mtype == 'normsys':
maskval = True if thismod else False
maskval = bool(thismod)
lo_factor = thismod['data']['lo'] if thismod else 1.0
hi_factor = thismod['data']['hi'] if thismod else 1.0
mega_mods[key][s]['data']['nom_data'] += [1.0] * len(nom)
Expand All @@ -171,7 +171,7 @@ def _nominal_and_modifiers_from_spec(config, spec):
nom
) # broadcasting
elif mtype in ['normfactor', 'shapefactor', 'lumi']:
maskval = True if thismod else False
maskval = bool(thismod)
mega_mods[key][s]['data']['mask'] += [maskval] * len(
nom
) # broadcasting
Expand All @@ -180,7 +180,7 @@ def _nominal_and_modifiers_from_spec(config, spec):
if mtype == 'shapesys':
maskval = [(x > 0 and y > 0) for x, y in zip(uncrt, nom)]
else:
maskval = [True if thismod else False] * len(nom)
maskval = [bool(thismod)] * len(nom)
mega_mods[key][s]['data']['mask'] += maskval
mega_mods[key][s]['data']['uncrt'] += uncrt
mega_mods[key][s]['data']['nom_data'] += nom
Expand Down
2 changes: 1 addition & 1 deletion src/pyhf/readxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def dedupe_parameters(parameters):
duplicates = {}
for p in parameters:
duplicates.setdefault(p['name'], []).append(p)
for parname in duplicates.keys():
for parname in duplicates:
parameter_list = duplicates[parname]
if len(parameter_list) == 1:
continue
Expand Down