Skip to content

Commit d92faa4

Browse files
committed
clean up _prune_and_rename
1 parent f231fc3 commit d92faa4

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/pyhf/workspace.py

+15-15
Original file line numberDiff line numberDiff line change
@@ -611,12 +611,11 @@ def _prune_and_rename(
611611
],
612612
}
613613
for channel in self['channels']
614+
# we want to remove channels only if no samples or modifiers are to be pruned
614615
if channel['name'] not in prune_channels
615-
or ( # we only want to remove this channel if we did not specify any samples or modifiers to prune
616-
prune_samples != []
617-
or prune_modifiers != []
618-
or prune_modifier_types != []
619-
)
616+
or prune_samples
617+
or prune_modifiers
618+
or prune_modifier_types
620619
],
621620
'measurements': [
622621
{
@@ -634,9 +633,11 @@ def _prune_and_rename(
634633
for parameter in measurement['config'][
635634
'parameters'
636635
] # we only want to remove this parameter if measurement is in prune_measurements or if prune_measurements is empty
636+
# we want to remove parameters from a measurement only
637+
# if measurement is not in keep_measurements
637638
if (
638-
measurement['name'] not in prune_measurements
639-
and prune_measurements != []
639+
prune_measurements
640+
and measurement['name'] not in prune_measurements
640641
)
641642
or parameter['name'] not in prune_modifiers
642643
],
@@ -646,22 +647,21 @@ def _prune_and_rename(
646647
},
647648
}
648649
for measurement in self['measurements']
649-
if measurement['name'] not in prune_measurements
650-
or prune_modifiers
651-
!= [] # we only want to remove this measurement if we did not specify parameters to remove
650+
# we want to remove measurements only if no parameters are to be pruned
651+
if measurement['name'] not in prune_measurements or prune_modifiers
652652
],
653653
'observations': [
654654
dict(
655655
copy.deepcopy(observation),
656656
name=rename_channels.get(observation['name'], observation['name']),
657657
)
658658
for observation in self['observations']
659+
# we want to remove this channels only
660+
# if no samples or modifiers are to be pruned
659661
if observation['name'] not in prune_channels
660-
or ( # we only want to remove this channel if we did not specify any samples or modifiers to prune
661-
prune_samples != []
662-
or prune_modifiers != []
663-
or prune_modifier_types != []
664-
)
662+
or prune_samples
663+
or prune_modifiers
664+
or prune_modifier_types
665665
],
666666
'version': self['version'],
667667
}

0 commit comments

Comments
 (0)