Break + lunch bugs (again)
We have another problem with breaks, picked up by Letizia from EP safety office (1). There's also an issue with lunchtimes (2). Since the solutions are going to be related, I'll put them both in this issue.
1) Break bug -
Here's the output - input is in attached screen shot. Clearly something is off with the division on the breaks in the case of 4 or 2 breaks for this scenario. I think the fact that the exposed is only present in the morning is throwing it off.
To clarify what the behaviour should be - I suggest that the breaks are split across the max interval (i.e. whatever happens earliest to whatever happens latest).
Traceback (most recent call last):
File "/opt/app-root/lib/python3.6/site-packages/tornado/web.py", line 1701, in _execute
result = method(*self.path_args, **self.path_kwargs)
File "/opt/app-root/src/cara/apps/calculator/__init__.py", line 37, in post
report = build_report(form.build_model(), form)
File "/opt/app-root/src/cara/apps/calculator/model_generator.py", line 134, in build_model
return model_from_form(self)
File "/opt/app-root/src/cara/apps/calculator/model_generator.py", line 397, in model_from_form
infected=form.infected_population(),
File "/opt/app-root/src/cara/apps/calculator/model_generator.py", line 231, in infected_population
presence=self.infected_present_interval(),
File "/opt/app-root/src/cara/apps/calculator/model_generator.py", line 346, in infected_present_interval
return self.present_interval(self.infected_start, self.infected_finish)
File "/opt/app-root/src/cara/apps/calculator/model_generator.py", line 303, in present_interval
for coffee_start, coffee_end in self.coffee_break_times():
File "/opt/app-root/src/cara/apps/calculator/model_generator.py", line 286, in coffee_break_times
self.activity_start, self.lunch_start, n_morning_breaks
File "/opt/app-root/src/cara/apps/calculator/model_generator.py", line 267, in _compute_breaks_in_interval
break_delay = ((finish - start) - (n_breaks * self.coffee_duration)) // (n_breaks+1)
ZeroDivisionError: integer division or modulo by zero
2) Lunch bug (again)
The lunch break is applied to the infected, but not to the exposed person, who's exposure/dose is still integrated over the lunch break - see attached PDF.
During lunch breaks, we should pause the integration of dose/risk and not shade the area on the exposure graph. I'm not 100% sure it's being integrated, but certainly shouldn't be shaded on the graph - coffee breaks are handled correctly. It's a boundary condition colision caused by the activity start time = lunch start time. If I adjust the lunch time to be 13:01 with the activity starting at 13:00 it calculates correctly. lunch_integration.pdf