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 deprecation warning for memoryreader inclusive indexing in timeseries. #3894

Merged
merged 11 commits into from
Nov 1, 2022
2 changes: 2 additions & 0 deletions package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ Changes
* adding element attribute to TXYZParser if all atom names are valid element symbols (PR #3826)

Deprecations
* Add deprecation warning for inclusive start, stop, step indexing
hmacdope marked this conversation as resolved.
Show resolved Hide resolved
in MemoryReader.timeseries (#PR 3894)


08/29/22 IAlibay, PicoCentauri, orbeckst, hmacdope, rmeli, miss77jun, rzhao271,
Expand Down
13 changes: 12 additions & 1 deletion package/MDAnalysis/coordinates/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,8 +502,12 @@ def timeseries(self, asel=None, start=0, stop=-1, step=1, order='afc'):
data is returned whenever `asel` is different from ``None``.
start : int (optional)
stop : int (optional)
Note that `stop` is currently *inclusive* but will be deprecated in
favour of being *exclusive* in 3.0.
hmacdope marked this conversation as resolved.
Show resolved Hide resolved
step : int (optional)
range of trajectory to access, `start` and `stop` are *inclusive*
hmacdope marked this conversation as resolved.
Show resolved Hide resolved
range of trajectory to access, `start` and `stop` are
hmacdope marked this conversation as resolved.
Show resolved Hide resolved
currently *inclusive* but will be changed to be *exclusive* in
3.0.
order : {"afc", "acf", "caf", "fac", "fca", "cfa"} (optional)
the order/shape of the return data array, corresponding
to (a)tom, (f)rame, (c)oordinates all six combinations
Expand All @@ -514,7 +518,14 @@ def timeseries(self, asel=None, start=0, stop=-1, step=1, order='afc'):

.. versionchanged:: 1.0.0
Deprecated `format` keyword has been removed. Use `order` instead.
.. versionchanged:: 2.4.0
hmacdope marked this conversation as resolved.
Show resolved Hide resolved
Deprecation warning
"""
if stop != -1:
warnings.warn("MemoryReader.timeseries inclusive `start` and `stop`"
hmacdope marked this conversation as resolved.
Show resolved Hide resolved
" indexing will be removed in 3.0 in favour of exclusive "
"indexing",category=DeprecationWarning)
orbeckst marked this conversation as resolved.
Show resolved Hide resolved

array = self.get_array()
if order == self.stored_order:
pass
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 @@ -197,6 +197,11 @@ def test_position_assignation(self, reader):
reader[0]
assert_almost_equal(reader.ts.positions, new_positions)

def test_timeseries_warns_deprecation(self, reader):
with pytest.warns(DeprecationWarning, match="MemoryReader.timeseries "
"inclusive"):
reader.timeseries(start=0, stop=3, step=1)


class TestMemoryReaderVelsForces(object):
@staticmethod
Expand Down