Skip to content

Comments

Appropriately handle skipped frames#44

Merged
IAlibay merged 32 commits intomainfrom
masked_frames
Jan 31, 2025
Merged

Appropriately handle skipped frames#44
IAlibay merged 32 commits intomainfrom
masked_frames

Conversation

@IAlibay
Copy link
Member

@IAlibay IAlibay commented Jan 20, 2025

Fixes #41

TODO:

  • upload relevant skipped NetCDF files somewhere
  • write more tests

Copy link
Contributor

@hannahbaumann hannahbaumann left a comment

Choose a reason for hiding this comment

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

Thanks @IAlibay , I know this is still [WIP] , so just some preliminary comments, but otherwise lgtm!

@hannahbaumann hannahbaumann self-assigned this Jan 21, 2025
IAlibay and others added 5 commits January 23, 2025 10:47
Co-authored-by: Hannah Baumann <43765638+hannahbaumann@users.noreply.github.com>
Co-authored-by: Hannah Baumann <43765638+hannahbaumann@users.noreply.github.com>
@IAlibay
Copy link
Member Author

IAlibay commented Jan 23, 2025

@hannahbaumann if you could take over here, especially with the tests that would be grand!

The figshare with the new files is here: https://figshare.com/articles/dataset/OpenFE_1_3_0beta_example_results_files/28263203

@IAlibay IAlibay added this to the v0.3.0 milestone Jan 23, 2025
@codecov
Copy link

codecov bot commented Jan 23, 2025

Codecov Report

Attention: Patch coverage is 88.46154% with 9 lines in your changes missing coverage. Please review.

Project coverage is 72.10%. Comparing base (f3a37f0) to head (faa5546).
Report is 18 commits behind head on main.

Files with missing lines Patch % Lines
src/openfe_analysis/utils/multistate.py 74.07% 7 Missing ⚠️
src/openfe_analysis/reader.py 94.11% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main      #44       +/-   ##
===========================================
+ Coverage   60.06%   72.10%   +12.03%     
===========================================
  Files           6        7        +1     
  Lines         298      337       +39     
===========================================
+ Hits          179      243       +64     
+ Misses        119       94       -25     

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

@hannahbaumann
Copy link
Contributor

The tests are quite flaky for some reason, I wonder if it's related to the size of the original NetCDF file. I added a pytest.mark.flaky for now.

@hannahbaumann
Copy link
Contributor

@IAlibay : I can't request a review from you since you had opened this PR (sorry, I should have made changes in a separate branch instead), could you review the small changes I made? I added the files for the skipped frames in the conftest.py and modified/added the test to check the positions and velocities.

Copy link
Member Author

@IAlibay IAlibay left a comment

Choose a reason for hiding this comment

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

Looks good @hannahbaumann - couple of things and then I think it's good to go.

assert u.trajectory.n_frames == 6
for ts in u.trajectory:
assert np.all(u.atoms.positions > 0)
with pytest.raises(mda.exceptions.NoDataError, match='This Timestep has no velocities'):
Copy link
Member Author

Choose a reason for hiding this comment

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

Possibly do this outside of the loop? As far as I remember, MDAnallysis doesn't support variable velocities, so if it fails on one timestep it'll fail on all timesteps.

range(0, dataset.dimensions['iteration'].size, dataset.PositionInterval)
]
else:
wmsg = ('This is an older NetCDF file that does not yet contain '
Copy link
Member Author

Choose a reason for hiding this comment

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

In the tests using the old file, could you wrap the universe creation with a pytest.warns that checks for this please?

will return ``None``.
"""
# Case: no box_vectors were stored at this frame
if dataset.variables['box_vectors'][frame_num][replica_index].mask.all():
Copy link
Member Author

Choose a reason for hiding this comment

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

Could you add a test in test_multistate with the skipped netcdf that tries to access the positions and unitcell at frame 1 and gets a None?

Copy link
Member Author

@IAlibay IAlibay left a comment

Choose a reason for hiding this comment

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

This looks good to me, thanks @hannahbaumann !

@hannahbaumann hannahbaumann changed the title [WIP] Appropriately handle skipped frames Appropriately handle skipped frames Jan 31, 2025
@IAlibay IAlibay merged commit 92ee58d into main Jan 31, 2025
11 checks passed
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 support for masked frames (i.e. positions missing at certain frames)

2 participants