13 Tests to enforce rules about how skims are defined.
26 Check that no skims use ma.applyEventCuts anywhere. BaseSkim.skim_event_cuts is
27 preferred, since ma.applyEventCuts is incompatible with CombinedSkim.
29 SkimsWithApplyEventCuts = set()
31 for skim
in Registry.names:
32 classdef = Registry.get_skim_function(skim)
33 source = inspect.getsource(classdef)
34 tree = ast.parse(source)
36 for node
in ast.walk(tree):
38 if not isinstance(node, ast.Call):
43 function = node.func.id
44 except AttributeError:
45 function = node.func.attr
47 if function ==
"applyEventCuts":
48 SkimsWithApplyEventCuts.add(skim)
50 if SkimsWithApplyEventCuts:
51 plural = len(SkimsWithApplyEventCuts) > 1
53 f
"The following skim{plural*'s'} use{(not plural)*'s'} "
54 "modularAnalysis.applyEventCuts, which cannot be used in skims: "
55 f
"{', '.join(SkimsWithApplyEventCuts)}. Please use "
56 "BaseSkim.skim_event_cuts instead."
60 if __name__ ==
"__main__":
def test_applyEventCuts_not_used(self)