Skip to content

Commit fd761f7

Browse files
committed
Exit as soon as condition is not met
1 parent d8e6922 commit fd761f7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/tlo/methods/collect_event_chains.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ def on_notification_event_about_to_run(self, data):
131131
# 1) generate_event_chains is set to True
132132
# 2) the event belongs to modules of interest and
133133
# 3) the event is not in the list of events to ignore
134-
if self.generate_event_chains and (data['module'] in self.modules_of_interest) and (data['link_info']['EventName'] not in self.events_to_ignore):
134+
if not self.generate_event_chains or (data['module'] not in self.modules_of_interest) or (data['link_info']['EventName'] in self.events_to_ignore):
135+
return
136+
else:
135137

136138
# Initialise these variables
137139
self.print_chains = False
@@ -174,7 +176,9 @@ def on_notification_event_about_to_run(self, data):
174176
def on_notification_event_has_just_ran(self, data):
175177
""" If print_chains=True, this function logs the event and identifies and logs the any property changes that have occured to one or multiple individuals as a result of the event taking place. """
176178

177-
if self.print_chains:
179+
if not self.print_chains:
180+
return
181+
else:
178182

179183
chain_links = {}
180184

0 commit comments

Comments
 (0)