mdanalysis
mdanalysis copied to clipboard
BUG: streamlines only returns the dx_array, dy_array of last frame
Expected behavior
From a skim over the docs and code my impression was that streamlines.generate_streamlines would incorporate all frames between start_frame and end_frame in the dx_array, but looking more closely at the code I'm not sure that happens. Is it supposed to?
Actual behavior
I can get this test to pass with start_frame=0, start_frame=1, and start_frame=2.
https://github.com/MDAnalysis/mdanalysis/blob/6ec838b0a018bc8cd2338ede866bbe78a184c6b2/testsuite/MDAnalysisTests/visualization/test_streamlines.py#L54-L80
Because xy_deltas_to_write is returned from this function, it looks like the results get re-set for each frame:
https://github.com/MDAnalysis/mdanalysis/blob/6ec838b0a018bc8cd2338ede866bbe78a184c6b2/package/MDAnalysis/visualization/streamlines.py#L201-L214
Current version of MDAnalysis
- Which version are you using? (run
python -c "import MDAnalysis as mda; print(mda.__version__)") - Which version of Python (
python -V)? - Which operating system?
@tylerjereddy could you please spare a quick glance 👀 here?
I saw the ping, I'll try to check soon-ish. I'm under some pressure to get SciPy released to support NumPy 2 series, but will try to make some time.
I agree with Lily that there's a bug here.
The lack of input validation is also pretty jarring, I can give an obscure floating point value to the test start frame value and it still passes (pretty silly):
--- a/testsuite/MDAnalysisTests/visualization/test_streamlines.py
+++ b/testsuite/MDAnalysisTests/visualization/test_streamlines.py
@@ -88,7 +88,7 @@ def test_streamplot_2D_zero_return(membrane_xtc, univ, tmpdir):
trajectory_file_path=membrane_xtc,
grid_spacing=20,
MDA_selection='name POX',
- start_frame=1,
+ start_frame=np.sqrt(17),
end_frame=2,
xmin=univ.atoms.positions[...,0].min(),
xmax=univ.atoms.positions[...,0].max(),
So yeah, definitely some issues here. Not sure that Lily should be burdened with fixing them all at this time, but definitely good to have issue(s) open so folks can be aware.
@tylerjereddy is this bug something you could fix?
Probably, it sounds like Lily may fix it during the refactor to AnalysisBase in any case though.