Skip to content

fix: guard CI variable access in plot_frequencies_time_series and plo…#1037

Open
adilraza99 wants to merge 6 commits intomalariagen:masterfrom
adilraza99:GH1035-plot-ci-guard
Open

fix: guard CI variable access in plot_frequencies_time_series and plo…#1037
adilraza99 wants to merge 6 commits intomalariagen:masterfrom
adilraza99:GH1035-plot-ci-guard

Conversation

@adilraza99
Copy link
Contributor

Summary

plot_frequencies_time_series() assumes that confidence interval variables (event_frequency_ci_low, event_frequency_ci_upp) are always present in the input dataset.

However, these variables are only added when ci_method is not None. When datasets are generated with ci_method=None, the plotting function raises a KeyError.

Fix

Guard access to CI variables in the plotting layer.

  • If CI variables are present → existing behaviour is preserved (error bars shown).
  • If CI variables are absent → plots render normally without error bars.

The same guard is applied to plot_frequencies_map_markers() to ensure consistent behaviour across frequency plotting functions.

Tests

Added tests covering datasets both with and without CI variables to ensure:

  • plotting works when CI variables are missing
  • existing behaviour remains unchanged when CI variables are present

Fixes #1035

@adilraza99 adilraza99 force-pushed the GH1035-plot-ci-guard branch from 0188ead to 3cb8e06 Compare March 4, 2026 03:17
@adilraza99 adilraza99 force-pushed the GH1035-plot-ci-guard branch from 3cb8e06 to d5dd128 Compare March 4, 2026 11:37
@codecov
Copy link

codecov bot commented Mar 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.12%. Comparing base (5ed1bb0) to head (f678422).
⚠️ Report is 101 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1037      +/-   ##
==========================================
+ Coverage   90.08%   90.12%   +0.03%     
==========================================
  Files          50       50              
  Lines        5428     5456      +28     
==========================================
+ Hits         4890     4917      +27     
- Misses        538      539       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@adilraza99
Copy link
Contributor Author

Hi @jonbrenas,

Would appreciate your thoughts on this approach. Please let me know if there’s anything else that should be adjusted or improved here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

plot_frequencies_time_series() does not handle missing CI variables when ci_method=None

1 participant