Skip to content

1290 add ABM visualization from paper to memilio plot #1291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 23 commits into
base: main
Choose a base branch
from

Conversation

xsaschako
Copy link
Member

@xsaschako xsaschako commented May 27, 2025

Changes and Information

Please briefly list the changes (main added features, changed items, or corrected bugs) made:

  • add visualization for the abm runs.

If need be, add additional information and what the reviewer should look out for in particular:

Merge Request - Guideline Checklist

Please check our git workflow. Use the draft feature if the Pull Request is not yet ready to review.

Checks by code author

  • Every addressed issue is linked (use the "Closes #ISSUE" keyword below)
  • New code adheres to coding guidelines
  • No large data files have been added (files should in sum not exceed 100 KB, avoid PDFs, Word docs, etc.)
  • Tests are added for new functionality and a local test run was successful (with and without OpenMP)
  • Appropriate documentation for new functionality has been added (Doxygen in the code and Markdown files if necessary)
  • Proper attention to licenses, especially no new third-party software with conflicting license has been added
  • (For ABM development) Checked benchmark results and ran and posted a local test above from before and after development to ensure performance is monitored.

Checks by code reviewer(s)

  • Corresponding issue(s) is/are linked and addressed
  • Code is clean of development artifacts (no deactivated or commented code lines, no debugging printouts, etc.)
  • Appropriate unit tests have been added, CI passes, code coverage and performance is acceptable (did not decrease)
  • No large data files added in the whole history of commits(files should in sum not exceed 100 KB, avoid PDFs, Word docs, etc.)
  • On merge, add 2-5 lines with the changes (main added features, changed items, or corrected bugs) to the merge-commit-message. This can be taken from the briefly-list-the-changes above (best case) or the separate commit messages (worst case).

@xsaschako xsaschako requested review from reneSchm and Copilot May 27, 2025 22:20
@xsaschako xsaschako self-assigned this May 27, 2025
@xsaschako xsaschako linked an issue May 27, 2025 that may be closed by this pull request
2 tasks
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds new visualization modules to support ABM simulation output analysis for infection states and ICU/death comparisons. Key changes include:

  • Introduction of plotAbmInfectionStates.py for visualizing infection states and spatial location types.
  • Introduction of plotAbmICUAndDeadComp.py for comparing ICU occupancy and deaths between simulation results and real-world data.
  • Addition of helper functions for file loading and axis formatting to support the new visualizations.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
pycode/memilio-plot/memilio/plot/plotAbmInfectionStates.py New module for plotting infection states and location types from simulation HDF5 data.
pycode/memilio-plot/memilio/plot/plotAbmICUAndDeadComp.py New module for plotting and comparing ICU occupancy and cumulative deaths with real-world data.
Comments suppressed due to low confidence (2)

pycode/memilio-plot/memilio/plot/plotAbmICUAndDeadComp.py:71

  • The variable 'age_grous_string' appears to be misspelled. Consider renaming it to 'age_groups_string' for clarity.
age_grous_string = ['Age 0-4', 'Age 5-14', 'Age 15-34', 'Age 35-59', 'Age 60-79', 'Age 80+'] # Adjust as needed

pycode/memilio-plot/memilio/plot/plotAbmICUAndDeadComp.py:30

  • Consider using a context manager (e.g., 'with h5py.File(..., 'r') as f:') when opening HDF5 files to ensure they are properly closed after reading.
f_p50 = h5py.File(path+"/infection_state_per_age_group/0/p50/Results.h5", 'r')

Copy link

codecov bot commented May 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.28%. Comparing base (83c57ad) to head (392ec54).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1291   +/-   ##
=======================================
  Coverage   97.28%   97.28%           
=======================================
  Files         168      168           
  Lines       14858    14858           
=======================================
  Hits        14454    14454           
  Misses        404      404           

☔ 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.

@mknaranja
Copy link
Member

Thanks for bringing this close to our previous plot style from the assessment paper. @jubicker Could you have a look for the detailed review?

@kilianvolmer kilianvolmer changed the title 1290 add abm visualization from paper to memilio plot 1290 add ABM visualization from paper to memilio plot Jun 2, 2025
@xsaschako xsaschako requested review from jubicker and removed request for reneSchm June 9, 2025 08:58
# * @brief Log the TimeSeries of the number of Person%s in an #InfectionState.
# * @param[in] sim The simulation of the abm.
# * @return A pair of the TimePoint and the TimeSeries of the number of Person%s in an #InfectionState.
# */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The @return description is still wrong

xtick_step=150,
y05=None, y95=None, show_90=False):
""" Plots infection states with percentiles and improved styling. """
plt.figure('Infection_states')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still missing

abm.plot_infections_loc_types_average('dummy_path')
assert mock_ax.plot.called
assert mock_ax.set_xticks.called
assert mock_ax.set_xticklabels.called
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where?

# Check that plot_infection_states was called with correct data structure
states_call_args = mock_states.call_args
self.assertIsNotNone(states_call_args)
self.assertEqual(len(states_call_args[0]), 7) # x, y50, y25, y75
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get the comment. There are for arguments but the assertion says 7

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

indiv_call_args = mock_indiv.call_args
self.assertIsNotNone(indiv_call_args)
# x, p50_bs, p25_bs, p75_bs
self.assertEqual(len(indiv_call_args[0]), 5)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here as above

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected

"fill_between should be called for confidence intervals")
fill_calls = mock_ax.fill_between.call_args_list
# Should have calls for both 50% and 90% confidence intervals if show_90=True
self.assertGreater(len(fill_calls), 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You do not check if it was called for the 90% confidence intervall. Please check if it was called exactly 2 times

expected_ticks = np.arange(0, len(x), 2) # xtick_step=2
np.testing.assert_array_equal(xticks_call, expected_ticks)

# Verify xticklabels are set correctly
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You only test whether the xtick labels have the correct size not if they are called correctly

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

show90=True
)

# Verify subplot was called with correct dimensions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment does not suit to code

Copy link
Member Author

@xsaschako xsaschako Jun 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed it a bit

@xsaschako xsaschako requested a review from jubicker June 21, 2025 14:04
@jubicker
Copy link
Member

There is one CI check failing (Which is not failing on the main).

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.

Add ABM visualization from paper to MEmilio-plot
3 participants