fixed mypy errors
This commit is contained in:
parent
106ceec1f9
commit
b79cb8779d
3 changed files with 7 additions and 8 deletions
|
|
@ -371,7 +371,7 @@ class CO2Data(BaseRequestHandler):
|
||||||
report_task = executor.submit(
|
report_task = executor.submit(
|
||||||
co2_model_generator.CO2FormData.build_model, form,
|
co2_model_generator.CO2FormData.build_model, form,
|
||||||
)
|
)
|
||||||
report: str = await asyncio.wrap_future(report_task)
|
report = await asyncio.wrap_future(report_task)
|
||||||
self.finish(dict(report.CO2_fit_params()))
|
self.finish(dict(report.CO2_fit_params()))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -178,12 +178,12 @@ class CO2FormData:
|
||||||
break_times = []
|
break_times = []
|
||||||
for n in population_breaks:
|
for n in population_breaks:
|
||||||
# Parse break times.
|
# Parse break times.
|
||||||
begin = time_string_to_minutes(n["start_time"])
|
begin = model_generator.time_string_to_minutes(n["start_time"])
|
||||||
end = time_string_to_minutes(n["finish_time"])
|
end = model_generator.time_string_to_minutes(n["finish_time"])
|
||||||
for time in [begin, end]:
|
for time in [begin, end]:
|
||||||
# For a specific break, the infected and exposed presence is the same.
|
# For a specific break, the infected and exposed presence is the same.
|
||||||
if not getattr(self, 'infected_start') < time < getattr(self, 'infected_finish'):
|
if not getattr(self, 'infected_start') < time < getattr(self, 'infected_finish'):
|
||||||
raise ValueError(f'All breaks should be within the simulation time. Got {time_minutes_to_string(time)}.')
|
raise ValueError(f'All breaks should be within the simulation time. Got {model_generator.time_minutes_to_string(time)}.')
|
||||||
|
|
||||||
break_times.append((begin, end))
|
break_times.append((begin, end))
|
||||||
return tuple(break_times)
|
return tuple(break_times)
|
||||||
|
|
|
||||||
|
|
@ -447,7 +447,7 @@ class CustomVentilation(_VentilationBase):
|
||||||
ventilation_value: PiecewiseConstant
|
ventilation_value: PiecewiseConstant
|
||||||
|
|
||||||
def transition_times(self, room: Room) -> typing.Set[float]:
|
def transition_times(self, room: Room) -> typing.Set[float]:
|
||||||
return self.ventilation_value.transition_times
|
return set(self.ventilation_value.transition_times)
|
||||||
|
|
||||||
def air_exchange(self, room: Room, time: float) -> _VectorisedFloat:
|
def air_exchange(self, room: Room, time: float) -> _VectorisedFloat:
|
||||||
return self.ventilation_value.value(time)
|
return self.ventilation_value.value(time)
|
||||||
|
|
@ -1496,7 +1496,7 @@ class CO2Data:
|
||||||
|
|
||||||
def CO2_concentrations_from_params(self,
|
def CO2_concentrations_from_params(self,
|
||||||
exhalation_rate: float,
|
exhalation_rate: float,
|
||||||
ventilation_values: typing.Tuple[float, ...]) -> typing.List[float]:
|
ventilation_values: typing.Tuple[float, ...]) -> typing.List[_VectorisedFloat]:
|
||||||
CO2_concentrations = CO2ConcentrationModel(
|
CO2_concentrations = CO2ConcentrationModel(
|
||||||
room=Room(volume=self.room_volume),
|
room=Room(volume=self.room_volume),
|
||||||
ventilation=CustomVentilation(PiecewiseConstant(
|
ventilation=CustomVentilation(PiecewiseConstant(
|
||||||
|
|
@ -1510,10 +1510,9 @@ class CO2Data:
|
||||||
host_immunity=0.
|
host_immunity=0.
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
return [CO2_concentrations.concentration(time) for time in self.times]
|
return [CO2_concentrations.concentration(time) for time in self.times]
|
||||||
|
|
||||||
def CO2_fit_params(self) -> typing.Dict[_VectorisedFloat, _VectorisedFloat]:
|
def CO2_fit_params(self):
|
||||||
if len(self.times) != len(self.CO2_concentrations):
|
if len(self.times) != len(self.CO2_concentrations):
|
||||||
raise ValueError('times and CO2_concentrations must have same length.')
|
raise ValueError('times and CO2_concentrations must have same length.')
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue