From e95b1479bf01d617d83614f720dc82138cc515dc Mon Sep 17 00:00:00 2001 From: Luis Aleixo Date: Mon, 4 Jul 2022 12:14:54 +0200 Subject: [PATCH 1/2] Fixed bug with short-range interactions --- cara/apps/calculator/report_generator.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/cara/apps/calculator/report_generator.py b/cara/apps/calculator/report_generator.py index 5731e6cb..a175e8c2 100644 --- a/cara/apps/calculator/report_generator.py +++ b/cara/apps/calculator/report_generator.py @@ -285,18 +285,22 @@ def scenario_statistics(mc_model: mc.ExposureModel, sample_times: typing.List[fl def comparison_report( + form: FormData, report_data: typing.Dict[str, typing.Any], scenarios: typing.Dict[str, mc.ExposureModel], sample_times: typing.List[float], executor_factory: typing.Callable[[], concurrent.futures.Executor], ): - statistics = { - 'Current scenario' : { - 'probability_of_infection': report_data['prob_inf'], - 'expected_new_cases': report_data['expected_new_cases'], - 'concentrations': report_data['concentrations'], + if (form.short_range_option == "short_range_no"): + statistics = { + 'Current scenario' : { + 'probability_of_infection': report_data['prob_inf'], + 'expected_new_cases': report_data['expected_new_cases'], + 'concentrations': report_data['concentrations'], + } } - } + else: + statistics = {} with executor_factory() as executor: results = executor.map( @@ -350,7 +354,7 @@ class ReportGenerator: context.update(report_data) alternative_scenarios = manufacture_alternative_scenarios(form) context['alternative_scenarios'] = comparison_report( - report_data, alternative_scenarios, scenario_sample_times, executor_factory=executor_factory, + form, report_data, alternative_scenarios, scenario_sample_times, executor_factory=executor_factory, ) context['permalink'] = generate_permalink(base_url, self.calculator_prefix, form) context['calculator_prefix'] = self.calculator_prefix From cb485b175ab6b8ceb51df2c89964894340c3e6a2 Mon Sep 17 00:00:00 2001 From: Luis Aleixo Date: Tue, 5 Jul 2022 13:46:29 +0200 Subject: [PATCH 2/2] added margin top to the alternative scenarios plots --- cara/apps/calculator/static/js/report.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cara/apps/calculator/static/js/report.js b/cara/apps/calculator/static/js/report.js index a6010221..add174ce 100644 --- a/cara/apps/calculator/static/js/report.js +++ b/cara/apps/calculator/static/js/report.js @@ -691,7 +691,7 @@ function draw_alternative_scenarios_plot(concentration_plot_svg_id, alternative_ highest_concentration = Math.max(highest_concentration, Math.max(...scenario_concentrations)); } - yRange.domain([0., highest_concentration]); + yRange.domain([0., highest_concentration*1.1]); yAxisEl.transition().duration(1000).call(yAxis); for (const [scenario_name, data] of Object.entries(data_for_scenarios)) {