Skip to content
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

Add warning for future change of argument name for timeseries from asel -> atomgroup #4343

Merged
merged 12 commits into from
Dec 3, 2023
2 changes: 2 additions & 0 deletions package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ Changes
`analysis.nucleicacids.WatsonCrickDist.results.distances` (Issue #3720, PR #3735)

Deprecations
* The `asel` argument to timeseries will be renamed to `atomgroup` in 3.0.0.
(Issue #3911)
* MDAnalysis.lib.util is deprecated and will be removed in version 3.0
(Issue #3649)
* The TRZ reader & writer are deprecated and will be removed in version 3.0
Expand Down
5 changes: 5 additions & 0 deletions package/MDAnalysis/coordinates/DCD.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,11 @@ def timeseries(self,
ValueError now raised instead of NoDataError for empty input
AtomGroup
"""
if asel:
hmacdope marked this conversation as resolved.
Show resolved Hide resolved
warnings.warn(
"asel argument to timeseries will be renamed to"
"'atomgroup' in 3.0, see #3911",
category=DeprecationWarning)

start, stop, step = self.check_slice_indices(start, stop, step)

Expand Down
6 changes: 6 additions & 0 deletions package/MDAnalysis/coordinates/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,12 @@ def timeseries(self, asel: Optional['AtomGroup']=None,

.. versionadded:: 2.4.0
"""
if asel:
Copy link
Member

Choose a reason for hiding this comment

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

Same as above, we should support both keyword arguments and docs should reflect this.

warnings.warn(
"asel argument to timeseries will be renamed to"
"'atomgroup' in 3.0, see #3911",
category=DeprecationWarning)

start, stop, step = self.check_slice_indices(start, stop, step)
nframes = len(range(start, stop, step))

Expand Down
6 changes: 6 additions & 0 deletions package/MDAnalysis/coordinates/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,12 @@ def timeseries(self, asel=None, start=0, stop=-1, step=1, order='afc'):
ValueError now raised instead of NoDataError for empty input
AtomGroup
"""
if asel:
Copy link
Member

Choose a reason for hiding this comment

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

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.

Done :)

warnings.warn(
"asel argument to timeseries will be renamed to"
"'atomgroup' in 3.0, see #3911",
category=DeprecationWarning)

if stop != -1:
warnings.warn("MemoryReader.timeseries inclusive `stop` "
"indexing will be removed in 3.0 in favour of exclusive "
Expand Down
6 changes: 6 additions & 0 deletions testsuite/MDAnalysisTests/coordinates/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,12 @@ def test_timeseries_empty_asel(self, reader):
with pytest.raises(ValueError, match="Timeseries requires at least"):
reader.timeseries(atoms)

def test_timeseries_asel_warns_deprecation(self, reader):
atoms = mda.Universe(reader.filename).select_atoms("index 1")
with pytest.warns(DeprecationWarning, match="asel argument to"):
timeseries = reader.timeseries(asel=atoms, order='fac')


class MultiframeReaderTest(BaseReaderTest):
def test_last_frame(self, ref, reader):
ts = reader[-1]
Expand Down
7 changes: 6 additions & 1 deletion testsuite/MDAnalysisTests/coordinates/test_dcd.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,12 @@ def test_timeseries_empty_selection(universe_dcd):
asel = universe_dcd.select_atoms('name FOO')
universe_dcd.trajectory.timeseries(asel=asel)


def test_timeseries_asel_warns_deprecation(universe_dcd):
hmacdope marked this conversation as resolved.
Show resolved Hide resolved
allframes = universe_dcd.trajectory.timeseries(order='afc')
asel = universe_dcd.atoms[[1, 2, 3, 4]]
with pytest.warns(DeprecationWarning, match="asel argument to"):
xyz = universe_dcd.trajectory.timeseries(asel=asel, order='afc')

hmacdope marked this conversation as resolved.
Show resolved Hide resolved
def test_reader_set_dt():
dt = 100
frame = 3
Expand Down
5 changes: 5 additions & 0 deletions testsuite/MDAnalysisTests/coordinates/test_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@ def test_timeseries_warns_deprecation(self, reader):
"inclusive"):
reader.timeseries(start=0, stop=3, step=1)

def test_timeseries_asel_warns_deprecation(self, ref, reader):
selection = ref.universe.atoms
with pytest.warns(DeprecationWarning, match="asel argument to"):
reader.timeseries(asel=selection)


class TestMemoryReaderVelsForces(object):
@staticmethod
Expand Down
Loading