Skip to content

Commit

Permalink
clean up _prune_and_rename
Browse files Browse the repository at this point in the history
  • Loading branch information
vaustrup committed Dec 8, 2023
1 parent f231fc3 commit d92faa4
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/pyhf/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,12 +611,11 @@ def _prune_and_rename(
],
}
for channel in self['channels']
# we want to remove channels only if no samples or modifiers are to be pruned
if channel['name'] not in prune_channels
or ( # we only want to remove this channel if we did not specify any samples or modifiers to prune
prune_samples != []
or prune_modifiers != []
or prune_modifier_types != []
)
or prune_samples
or prune_modifiers
or prune_modifier_types
],
'measurements': [
{
Expand All @@ -634,9 +633,11 @@ def _prune_and_rename(
for parameter in measurement['config'][
'parameters'
] # we only want to remove this parameter if measurement is in prune_measurements or if prune_measurements is empty
# we want to remove parameters from a measurement only
# if measurement is not in keep_measurements
if (
measurement['name'] not in prune_measurements
and prune_measurements != []
prune_measurements
and measurement['name'] not in prune_measurements
)
or parameter['name'] not in prune_modifiers
],
Expand All @@ -646,22 +647,21 @@ def _prune_and_rename(
},
}
for measurement in self['measurements']
if measurement['name'] not in prune_measurements
or prune_modifiers
!= [] # we only want to remove this measurement if we did not specify parameters to remove
# we want to remove measurements only if no parameters are to be pruned
if measurement['name'] not in prune_measurements or prune_modifiers
],
'observations': [
dict(
copy.deepcopy(observation),
name=rename_channels.get(observation['name'], observation['name']),
)
for observation in self['observations']
# we want to remove this channels only
# if no samples or modifiers are to be pruned
if observation['name'] not in prune_channels
or ( # we only want to remove this channel if we did not specify any samples or modifiers to prune
prune_samples != []
or prune_modifiers != []
or prune_modifier_types != []
)
or prune_samples
or prune_modifiers
or prune_modifier_types
],
'version': self['version'],
}
Expand Down

0 comments on commit d92faa4

Please sign in to comment.