diff --git a/package/AUTHORS b/package/AUTHORS index c8ba87c062..b8af571375 100644 --- a/package/AUTHORS +++ b/package/AUTHORS @@ -281,6 +281,7 @@ Chronological list of authors - Amarendra Mohan - Shubham Mittal - Charity Grey + - barlowa124 - Sai Udayagiri - Apoorva Verma - Aryaman Chaudhri diff --git a/package/CHANGELOG b/package/CHANGELOG index 45647f3904..55c10927bb 100644 --- a/package/CHANGELOG +++ b/package/CHANGELOG @@ -18,7 +18,7 @@ The rules for this file: spyke7, talagayev, tanii1125, BradyAJohnston, hejamu, jeremyleung521, harshitgajjela-droid, kunjsinha, aygarwal, jauy123, Dreamstick9, ollyfutur, Amarendra22, charity-g, ParthUppal523, apoorva-01, RMeli, - raulloiscuns, Aryaman-Chaudhri, sici17 + raulloiscuns, Aryaman-Chaudhri, sici17, barlowa124 * 2.11.0 @@ -33,6 +33,9 @@ Fixes apply their fit via `AtomGroup.rotate()`. Note: this changes existing behavior, as velocities/forces were previously left untouched by rotation. (Issue #5421, PR #5452) + * `AnalysisBase.run()` no longer misinterprets NumPy boolean masks passed + via the ``frames`` argument as integer frame indices, which silently + selected the wrong frames (Issue #5472, PR #5480). * Fix FileLock tests for XTC and TRR: lock file is no longer removed (#5382) * InterRDF now correctly returns bins in parallel (PR #5344) * `Merge()` no longer raises a TypeError on Universes that have a `cmaps` diff --git a/package/MDAnalysis/analysis/base.py b/package/MDAnalysis/analysis/base.py index f18b866951..3a8824b84c 100644 --- a/package/MDAnalysis/analysis/base.py +++ b/package/MDAnalysis/analysis/base.py @@ -616,7 +616,7 @@ def _setup_computation_groups( else: used_frames = frames - if all(isinstance(obj, bool) for obj in used_frames): + if all(isinstance(obj, (bool, np.bool_)) for obj in used_frames): arange = np.arange(len(used_frames)) used_frames = arange[used_frames] diff --git a/testsuite/MDAnalysisTests/analysis/test_base.py b/testsuite/MDAnalysisTests/analysis/test_base.py index 0dd872bde5..64cee58d29 100644 --- a/testsuite/MDAnalysisTests/analysis/test_base.py +++ b/testsuite/MDAnalysisTests/analysis/test_base.py @@ -337,6 +337,26 @@ def test_start_stop_step(u, run_kwargs, frames): }, (0, 1, 3, 5, 6, 8), ), + ( + { + "frames": np.array( + [ + True, + True, + False, + True, + False, + True, + True, + False, + True, + False, + ], + dtype=bool, + ) + }, + (0, 1, 3, 5, 6, 8), + ), ], ) def test_frame_slice(u_xtc, run_kwargs, frames): @@ -370,6 +390,26 @@ def test_frame_slice(u_xtc, run_kwargs, frames): }, (0, 1, 3, 5, 6, 8), ), + ( + { + "frames": np.array( + [ + True, + True, + False, + True, + False, + True, + True, + False, + True, + False, + ], + dtype=bool, + ) + }, + (0, 1, 3, 5, 6, 8), + ), ], ) def test_frame_slice_parallel(run_kwargs, frames, client_FrameAnalysis):