Skip to content

Commit

Permalink
Trajectory slicing made completely pythonic MDAnalysis#918
Browse files Browse the repository at this point in the history
  • Loading branch information
shobhitagarwal1612 committed Jan 30, 2017
1 parent d83fc3b commit 2e3520c
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions package/MDAnalysis/coordinates/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,6 @@ def __getitem__(self, frame):
----
*frame* is a 0-based frame index.
"""

def apply_limits(frame):
if frame < 0:
frame += len(self)
Expand All @@ -1214,7 +1213,6 @@ def listiter(frames):
if not isinstance(f, (int, np.integer)):
raise TypeError("Frames indices must be integers")
yield self._read_frame_with_aux(apply_limits(f))

return listiter(frame)
elif isinstance(frame, slice):
start, stop, step = self.check_slice_indices(
Expand Down Expand Up @@ -1431,7 +1429,7 @@ def next_as_aux(self, auxname):
aux = self._check_for_aux(auxname)
ts = self.ts
# catch up auxiliary if it starts earlier than trajectory
while aux.step_to_frame(aux.step + 1, ts) < 0:
while aux.step_to_frame(aux.step+1, ts) < 0:
next(aux)
# find the next frame that'll have a representative value
next_frame = aux.next_nonempty_frame(ts)
Expand Down Expand Up @@ -1565,6 +1563,7 @@ def rename_aux(self, auxname, new):
setattr(self.ts.aux, new, self.ts.aux[auxname])
delattr(self.ts.aux, auxname)


def get_aux_descriptions(self, auxnames=None):
"""Get descriptions to allow reloading the specified auxiliaries.
Expand Down Expand Up @@ -1595,6 +1594,7 @@ def get_aux_descriptions(self, auxnames=None):
return descriptions



class Reader(ProtoReader):
"""Base class for trajectory readers that extends :class:`ProtoReader` with a
:meth:`__del__` method.
Expand All @@ -1619,7 +1619,6 @@ class Reader(ProtoReader):
Provides kwargs to be passed to :class:`Timestep`
"""

def __init__(self, filename, convert_units=None, **kwargs):
super(Reader, self).__init__()

Expand Down Expand Up @@ -1673,7 +1672,6 @@ class Writer(six.with_metaclass(_Writermeta, IObase)):
See Trajectory API definition in :mod:`MDAnalysis.coordinates.__init__` for
the required attributes and methods.
"""

def convert_dimensions_to_unitcell(self, ts, inplace=True):
"""Read dimensions from timestep *ts* and return appropriate unitcell.
Expand Down Expand Up @@ -1740,7 +1738,7 @@ def has_valid_coordinates(self, criteria, x):
x = np.ravel(x)
return np.all(criteria["min"] < x) and np.all(x <= criteria["max"])

# def write_next_timestep(self, ts=None)
# def write_next_timestep(self, ts=None)


class SingleFrameReader(ProtoReader):
Expand Down

0 comments on commit 2e3520c

Please sign in to comment.