From 2b475290b81edb9235e1a8bee00c8c9451844dae Mon Sep 17 00:00:00 2001 From: Luis Aleixo Date: Tue, 24 Jan 2023 16:42:08 +0100 Subject: [PATCH] fixed mypy errors --- caimira/apps/simulator.py | 6 +++--- caimira/models.py | 9 +++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/caimira/apps/simulator.py b/caimira/apps/simulator.py index f8de9148..4b1a1ace 100644 --- a/caimira/apps/simulator.py +++ b/caimira/apps/simulator.py @@ -124,8 +124,8 @@ def update_plot(self, model: models.CO2ConcentrationModel): figure_legends = [mlines.Line2D([], [], color='#3530fe', markersize=15, label='CO₂ concentration'), patches.Patch(edgecolor="#96cbff", facecolor='#96cbff', label='Presence of person(s)')] self.ax.legend(handles=figure_legends) - if 1500 < max(concentration): - self.ax.set_ylim(top=max(concentration)*1.1) + if 1500 < concentration_top: + self.ax.set_ylim(top=concentration_top*1.1) else: self.ax.set_ylim(top=1550) self.ax.hlines([800, 1500], xmin=min(model.CO2_emitters.presence.boundaries()[0])*0.95, xmax=max(model.CO2_emitters.presence.boundaries()[1])*1.05, colors=['limegreen', 'salmon'], linestyles='dashed') @@ -139,7 +139,7 @@ def __init__(self) -> None: #: A list of scenario name and ModelState instances. This is intended to be #: mutated. Any mutation should notify the appropriate Views for handling. - self._model_scenarios = [] + self._model_scenarios: typing.List[ScenarioType] = [] self._active_scenario = 0 self.multi_model_view = MultiModelView(self) # self.comparison_view = ExposureComparissonResult() diff --git a/caimira/models.py b/caimira/models.py index be9f3dd4..50b17978 100644 --- a/caimira/models.py +++ b/caimira/models.py @@ -1008,11 +1008,12 @@ def _normed_concentration_limit(self, time: float) -> _VectorisedFloat: if not self.population.person_present(time): return self.min_background_concentration()/self.normalization_factor() V = self.room.volume - # RR = self.removal_rate(time) if self.removal_rate(time) != 0 else 0.25 RR = self.removal_rate(time) - - return (1. / (RR * V) + self.min_background_concentration()/ + try: + return (1. / (RR * V) + self.min_background_concentration()/ self.normalization_factor()) + except ZeroDivisionError: + return 0 @method_cache def state_change_times(self) -> typing.List[float]: @@ -1206,7 +1207,7 @@ def population(self) -> Population: return self.CO2_emitters def removal_rate(self, time: float) -> _VectorisedFloat: - return self.ventilation.air_exchange(self.room, time) + 0.25 + return self.ventilation.air_exchange(self.room, time) def min_background_concentration(self) -> _VectorisedFloat: """