diff --git a/package/AUTHORS b/package/AUTHORS index 43e64e745dc..ddf90deb383 100644 --- a/package/AUTHORS +++ b/package/AUTHORS @@ -81,6 +81,7 @@ Chronological list of authors - Shantanu Srivastava 2017 - Utkarsh Bansal + - Shobhit Agarwal - Vedant Rathore External code diff --git a/package/CHANGELOG b/package/CHANGELOG index 79c5866ea6a..26e94eacc45 100644 --- a/package/CHANGELOG +++ b/package/CHANGELOG @@ -15,7 +15,7 @@ The rules for this file: ------------------------------------------------------------------------------ ??/??/16 kain88-de, fiona-naughton, richardjgowers, tyler.je.reddy, jdetle euhruska, orbeckst, rbrtdlg, jbarnoud, wouterboomsma, shanmbic, - dotsdl, manuel.nuno.melo, utkbansal, vedantrathore + dotsdl, manuel.nuno.melo, utkbansal, vedantrathore, shobhitagarwal1612 * 0.16.0 @@ -61,6 +61,7 @@ Enhancements * Added groupby method to Group objects. (PR #1112) Fixes + * Trajectory slicing made completely Pythonic (Issue #918 PR #1195) * Argument validation of dist_mat_to_vec is fixed (#597 PR #1183) * Give correct error when the topology file format is not recognized (Issue #982) * Give correct error when file doesn't exist/ has bad permissions (Issue #981) diff --git a/package/MDAnalysis/analysis/base.py b/package/MDAnalysis/analysis/base.py index da37fb18be9..65ed3e5ffdf 100644 --- a/package/MDAnalysis/analysis/base.py +++ b/package/MDAnalysis/analysis/base.py @@ -27,13 +27,12 @@ classes. """ +import six from six.moves import range, zip - import inspect import logging -import numpy as np -import six +import numpy as np from MDAnalysis import coordinates from MDAnalysis.core.groups import AtomGroup from MDAnalysis.lib.log import ProgressMeter, _set_verbose @@ -126,10 +125,10 @@ def _setup_frames(self, trajectory, start=None, stop=None, step=None): number of frames to skip between each analysed frame """ self._trajectory = trajectory - start, stop, step = trajectory.check_slice_indices(start, stop, step) self.start = start self.stop = stop self.step = step + start, stop, step = trajectory.check_slice_indices(start, stop, step) self.n_frames = len(range(start, stop, step)) interval = int(self.n_frames // 100) if interval == 0: @@ -223,7 +222,7 @@ def __init__(self, function, trajectory=None, *args, **kwargs): """ if (trajectory is not None) and (not isinstance( trajectory, coordinates.base.Reader)): - args = args + (trajectory, ) + args = args + (trajectory,) trajectory = None if trajectory is None: diff --git a/package/MDAnalysis/analysis/contacts.py b/package/MDAnalysis/analysis/contacts.py index a3fb4a6a4db..1f533e54f15 100644 --- a/package/MDAnalysis/analysis/contacts.py +++ b/package/MDAnalysis/analysis/contacts.py @@ -212,12 +212,12 @@ def is_any_closer(r, r0, dist=2.5): """ from __future__ import division +from six.moves import zip import os import errno import warnings import bz2 -from six.moves import zip import numpy as np from numpy.lib.utils import deprecate diff --git a/package/MDAnalysis/coordinates/base.py b/package/MDAnalysis/coordinates/base.py index d91e2120819..9b1ab0c41d9 100644 --- a/package/MDAnalysis/coordinates/base.py +++ b/package/MDAnalysis/coordinates/base.py @@ -123,29 +123,27 @@ """ from __future__ import absolute_import - -from six.moves import range import six - -import warnings +from six.moves import range import numpy as np import copy +import warnings import weakref +from . import core +from .. import NoDataError from .. import ( _READERS, _SINGLEFRAME_WRITERS, _MULTIFRAME_WRITERS, ) -from ..core import flags from .. import units -from ..lib.util import asiterable, Namespace -from . import core -from .. import NoDataError - from ..auxiliary.base import AuxReader from ..auxiliary.core import auxreader +from ..core import flags +from ..lib.util import asiterable, Namespace + class Timestep(object): """Timestep data for one frame @@ -1191,6 +1189,7 @@ def __getitem__(self, frame): ---- *frame* is a 0-based frame index. """ + def apply_limits(frame): if frame < 0: frame += len(self) @@ -1214,6 +1213,7 @@ 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( @@ -1277,6 +1277,21 @@ def check_slice_indices(self, start, stop, step): ------- start, stop, step : int Integers representing the slice + + Warning + ------- + The returned values start, stop and step give the expected result when passed + in range() but gives unexpected behaviour when passed in a slice when stop=None + and step=-1 + + This is because when we slice the trajectory (u.trajectory[::-1]), the values + returned by check_slice_indices are passed to range. Instead, in AnalysisBase + the values returned by check_slice_indices are used to splice the trajectory. + This creates a discrepancy because these two lines are not equivalent: + + range(10, -1, -1) # [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0] + range(10)[10:-1:-1] # [] + """ for var, varname in ( (start, 'start'), @@ -1295,33 +1310,30 @@ def check_slice_indices(self, start, stop, step): start = 0 if step > 0 else nframes - 1 elif start < 0: start += nframes + if start < 0: + start = 0 - if stop is not None: - if stop < 0: - stop += nframes - elif stop > nframes: - stop = nframes - else: + if step < 0 and start > nframes: + start = nframes - 1 + + if stop is None: stop = nframes if step > 0 else -1 + elif stop < 0: + stop += nframes - if step > 0 and stop < start: - raise IndexError("Stop frame is lower than start frame") - elif step < 0 and start < stop: - raise IndexError("Start frame is lower than stop frame") - if not (0 <= start < nframes) or stop > nframes: - raise IndexError( - "Frame start/stop outside of the range of the trajectory.") + if step > 0 and stop > nframes: + stop = nframes return start, stop, step def __repr__(self): return ("<{cls} {fname} with {nframes} frames of {natoms} atoms>" "".format( - cls=self.__class__.__name__, - fname=self.filename, - nframes=self.n_frames, - natoms=self.n_atoms - )) + cls=self.__class__.__name__, + fname=self.filename, + nframes=self.n_frames, + natoms=self.n_atoms + )) def add_auxiliary(self, auxname, auxdata, format=None, **kwargs): """Add auxiliary data to be read alongside trajectory. @@ -1421,7 +1433,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) @@ -1555,7 +1567,6 @@ 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. @@ -1586,7 +1597,6 @@ 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. @@ -1611,6 +1621,7 @@ class Reader(ProtoReader): Provides kwargs to be passed to :class:`Timestep` """ + def __init__(self, filename, convert_units=None, **kwargs): super(Reader, self).__init__() @@ -1664,6 +1675,7 @@ 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. @@ -1730,7 +1742,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): diff --git a/package/MDAnalysis/lib/mdamath.py b/package/MDAnalysis/lib/mdamath.py index 6472214fbf2..329956ba24e 100644 --- a/package/MDAnalysis/lib/mdamath.py +++ b/package/MDAnalysis/lib/mdamath.py @@ -38,8 +38,8 @@ .. versionadded:: 0.11.0 """ -import numpy as np from six.moves import zip +import numpy as np from ..exceptions import NoDataError diff --git a/package/MDAnalysis/lib/util.py b/package/MDAnalysis/lib/util.py index 34d42eb458b..4b80a15ec60 100644 --- a/package/MDAnalysis/lib/util.py +++ b/package/MDAnalysis/lib/util.py @@ -154,12 +154,12 @@ .. versionchanged:: 0.11.0 Moved mathematical functions into lib.mdamath """ +import six +from six.moves import range, map import sys __docformat__ = "restructuredtext en" -from six.moves import range, map -import six import os import os.path diff --git a/package/MDAnalysis/topology/TOPParser.py b/package/MDAnalysis/topology/TOPParser.py index ddb13061068..f0682794734 100644 --- a/package/MDAnalysis/topology/TOPParser.py +++ b/package/MDAnalysis/topology/TOPParser.py @@ -70,8 +70,8 @@ """ from __future__ import absolute_import, division -import numpy as np from six.moves import range, zip +import numpy as np import functools from math import ceil diff --git a/package/MDAnalysis/topology/XYZParser.py b/package/MDAnalysis/topology/XYZParser.py index 3345e8f39e3..9e730ef9252 100644 --- a/package/MDAnalysis/topology/XYZParser.py +++ b/package/MDAnalysis/topology/XYZParser.py @@ -39,8 +39,8 @@ """ from __future__ import absolute_import -import numpy as np from six.moves import range +import numpy as np from . import guessers from ..lib.util import openany diff --git a/package/MDAnalysis/topology/tpr/utils.py b/package/MDAnalysis/topology/tpr/utils.py index cd2ed35a5db..4567a7d9d40 100644 --- a/package/MDAnalysis/topology/tpr/utils.py +++ b/package/MDAnalysis/topology/tpr/utils.py @@ -47,8 +47,8 @@ """ from __future__ import absolute_import -import numpy as np from six.moves import range +import numpy as np from . import obj from . import setting as S diff --git a/testsuite/AUTHORS b/testsuite/AUTHORS index 5dc674d5986..bbb809ad9b3 100644 --- a/testsuite/AUTHORS +++ b/testsuite/AUTHORS @@ -73,6 +73,7 @@ Chronological list of authors 2017 - Utkarsh Bansal + - Shobhit Agarwal - Vedant Rathore External code diff --git a/testsuite/MDAnalysisTests/coordinates/test_pdb.py b/testsuite/MDAnalysisTests/coordinates/test_pdb.py index 7ddfcd50e12..8064b850a11 100644 --- a/testsuite/MDAnalysisTests/coordinates/test_pdb.py +++ b/testsuite/MDAnalysisTests/coordinates/test_pdb.py @@ -1,26 +1,23 @@ from six import StringIO from six.moves import zip - -import MDAnalysis as mda -import numpy as np import os - -from nose.plugins.attrib import attr -from numpy.testing import (assert_equal, assert_, dec, - assert_array_almost_equal, - assert_almost_equal, assert_raises, assert_) from unittest import TestCase +import MDAnalysis as mda +import numpy as np +from MDAnalysisTests import parser_not_found, tempdir, make_Universe +from MDAnalysisTests.coordinates.base import _SingleFrameReader from MDAnalysisTests.coordinates.reference import (RefAdKSmall, Ref4e43, RefAdK) -from MDAnalysisTests.coordinates.base import _SingleFrameReader from MDAnalysisTests.datafiles import (PDB, PDB_small, PDB_multiframe, XPDB_small, PSF, DCD, CONECT, CRD, INC_PDB, PDB_xlserial, ALIGN, ENT, PDB_cm, PDB_cm_gz, PDB_cm_bz2, PDB_mc, PDB_mc_gz, PDB_mc_bz2) -from MDAnalysisTests.plugins.knownfailure import knownfailure -from MDAnalysisTests import parser_not_found, tempdir, make_Universe +from nose.plugins.attrib import attr +from numpy.testing import (assert_equal, dec, + assert_array_almost_equal, + assert_almost_equal, assert_raises, assert_) class TestPDBReader(_SingleFrameReader): @@ -31,14 +28,12 @@ def setUp(self): # http://www.wwpdb.org/documentation/format32/sect9.html#ATOM self.prec = 3 - def test_uses_PDBReader(self): from MDAnalysis.coordinates.PDB import PDBReader assert_(isinstance(self.universe.trajectory, PDBReader), "failed to choose PDBReader") - def test_dimensions(self): assert_almost_equal( self.universe.trajectory.ts.dimensions, RefAdKSmall.ref_unitcell, @@ -49,12 +44,10 @@ def test_ENT(self): from MDAnalysis.coordinates.PDB import PDBReader self.universe = mda.Universe(ENT) assert_(isinstance(self.universe.trajectory, PDBReader), - "failed to choose PDBReader") + "failed to choose PDBReader") class _PDBMetadata(TestCase, Ref4e43): - - def setUp(self): self.universe = mda.Universe(self.filename) @@ -114,7 +107,6 @@ def test_REMARK(self): err_msg="REMARK line {0} do not match".format(lineno)) - class TestExtendedPDBReader(_SingleFrameReader): def setUp(self): self.universe = mda.Universe(PDB_small, @@ -145,12 +137,11 @@ def setUp(self): self.tmpdir = tempdir.TempDir() self.outfile = self.tmpdir.name + '/primitive-pdb-writer' + ext self.u_no_resnames = make_Universe(['names', 'resids'], - trajectory=True) + trajectory=True) self.u_no_resids = make_Universe(['names', 'resnames'], - trajectory=True) + trajectory=True) self.u_no_names = make_Universe(['resids', 'resnames'], - trajectory=True) - + trajectory=True) def tearDown(self): try: @@ -168,7 +159,7 @@ def test_writer(self): assert_almost_equal(u.atoms.positions, self.universe.atoms.positions, self.prec, err_msg="Writing PDB file with PDBWriter " - "does not reproduce original coordinates") + "does not reproduce original coordinates") @dec.slow def test_writer_no_resnames(self): @@ -253,8 +244,8 @@ def test_write_single_frame_AtomGroup(self): err_msg="Output PDB should only contain a single frame") assert_almost_equal(u2.atoms.positions, u.atoms.positions, self.prec, err_msg="Written coordinates do not " - "agree with original coordinates from frame %d" % - u.trajectory.frame) + "agree with original coordinates from frame %d" % + u.trajectory.frame) @attr('issue') def test_check_coordinate_limits_min(self): @@ -322,9 +313,9 @@ def test_n_atoms_frame(self): desired = 392 for frame in u.trajectory: assert_equal(len(u.atoms), desired, err_msg="The number of atoms " - "in the Universe (%d) does not" " match the number " - "of atoms in the test case (%d) at frame %d" % ( - len(u.atoms), desired, u.trajectory.frame)) + "in the Universe (%d) does not" " match the number " + "of atoms in the test case (%d) at frame %d" % ( + len(u.atoms), desired, u.trajectory.frame)) @attr('slow') def test_rewind(self): @@ -394,7 +385,7 @@ def test_conect_bonds_all(self): assert_equal(len(u2.atoms), 1890) assert_equal(len([b for b in u2.bonds if not b.is_guessed]), 1922) - #assert_equal(len([b for b in conect.bonds if not b.is_guessed]), 1922) + # assert_equal(len([b for b in conect.bonds if not b.is_guessed]), 1922) @attr('slow') def test_numconnections(self): @@ -453,8 +444,8 @@ def helper(atoms, bonds): conect = helper(self.multiverse.atoms, [b for b in u.bonds if not b.is_guessed]) assert_equal(conect, desired, err_msg="The bond list does not match " - "the test reference; len(actual) is %d, len(desired) " - "is %d" % (len(u._topology.bonds.values), len(desired))) + "the test reference; len(actual) is %d, len(desired) " + "is %d" % (len(u._topology.bonds.values), len(desired))) class TestMultiPDBWriter(TestCase): @@ -499,13 +490,13 @@ def test_write_atomselection(self): u2 = mda.Universe(self.outfile) assert_equal(len(u2.atoms), desired_group, err_msg="MultiPDBWriter trajectory written for an " - "AtomGroup contains %d atoms, it should contain %d" % ( - len(u2.atoms), desired_group)) + "AtomGroup contains %d atoms, it should contain %d" % ( + len(u2.atoms), desired_group)) assert_equal(len(u2.trajectory), desired_frames, err_msg="MultiPDBWriter trajectory written for an " - "AtomGroup contains %d frames, it should have %d" % ( - len(u.trajectory), desired_frames)) + "AtomGroup contains %d frames, it should have %d" % ( + len(u.trajectory), desired_frames)) @attr('slow') def test_write_all_timesteps(self): @@ -523,13 +514,13 @@ def test_write_all_timesteps(self): u2 = mda.Universe(self.outfile) assert_equal(len(u2.atoms), desired_group, err_msg="MultiPDBWriter trajectory written for an " - "AtomGroup contains %d atoms, it should contain %d" % ( - len(u2.atoms), desired_group)) + "AtomGroup contains %d atoms, it should contain %d" % ( + len(u2.atoms), desired_group)) assert_equal(len(u2.trajectory), desired_frames, err_msg="MultiPDBWriter trajectory written for an " - "AtomGroup contains %d frames, it should have %d" % ( - len(u.trajectory), desired_frames)) + "AtomGroup contains %d frames, it should have %d" % ( + len(u.trajectory), desired_frames)) @attr('slow') def test_write_atoms(self): @@ -737,6 +728,7 @@ def test_uses_PDBReader(self): class TestPDBWriterOccupancies(object): """Tests for Issue #620""" + def setUp(self): self.tempdir = tempdir.TempDir() self.outfile = self.tempdir.name + '/occ.pdb' @@ -784,19 +776,22 @@ def test_atomtype_alignment(self): " 1.00 0.00 RNAA H\n") assert_equal(self.writtenstuff[4], result_line) + def test_deduce_PDB_atom_name(): # The Pair named tuple is used to mock atoms as we only need them to have a # ``resname`` and a ``name`` attribute. Pair = mda.coordinates.PDB.Pair + def _test_PDB_atom_name(atom, ref_atom_name): dummy_file = StringIO() name = (mda.coordinates.PDB.PrimitivePDBWriter(dummy_file, n_atoms=1) ._deduce_PDB_atom_name(atom.name, atom.resname)) assert_equal(name, ref_atom_name) + test_cases = ((Pair('ASP', 'CA'), ' CA '), # Regular protein carbon alpha (Pair('GLU', 'OE1'), ' OE1'), (Pair('MSE', 'SE'), 'SE '), # Selenium like in 4D3L - (Pair('CA', 'CA'), 'CA '), # Calcium like in 4D3L + (Pair('CA', 'CA'), 'CA '), # Calcium like in 4D3L (Pair('HDD', 'FE'), 'FE '), # Iron from a heme like in 1GGE (Pair('PLC', 'P'), ' P '), # Lipid phosphorus (1EIN) ) @@ -856,7 +851,7 @@ def _check_seekaround(self, pdbfile): u.trajectory[frame] assert_almost_equal(u.dimensions[0], self.boxsize[frame]) assert_almost_equal(u.atoms[0].position[0], self.position[frame]) - + def _check_rewind(self, pdbfile): u = mda.Universe(pdbfile) @@ -872,6 +867,7 @@ def test_standalone_pdb(): assert_(r.n_atoms == 4) + def test_write_pdb_zero_atoms(): # issue 1083 u = make_Universe(trajectory=True) @@ -883,4 +879,3 @@ def test_write_pdb_zero_atoms(): with mda.Writer(outfile, ag.n_atoms) as w: assert_raises(IndexError, w.write, ag) - diff --git a/testsuite/MDAnalysisTests/coordinates/test_reader_api.py b/testsuite/MDAnalysisTests/coordinates/test_reader_api.py index d2f80a5ff2e..b06eac2464a 100644 --- a/testsuite/MDAnalysisTests/coordinates/test_reader_api.py +++ b/testsuite/MDAnalysisTests/coordinates/test_reader_api.py @@ -20,15 +20,15 @@ # J. Comput. Chem. 32 (2011), 2319--2327, doi:10.1002/jcc.21787 # +import numpy as np from MDAnalysis.coordinates.base import Timestep, SingleFrameReader, Reader - from numpy.testing import assert_equal, assert_raises -import numpy as np """ Isolate the API definitions of Readers independent of implementations """ + class AmazingMultiFrameReader(Reader): format = 'AmazingMulti' @@ -43,14 +43,13 @@ def __init__(self, filename, **kwargs): self.ts.frame = -1 self._read_next_timestep() - def _read_next_timestep(self): self.ts.frame += 1 if (self.ts.frame + 1) > self.n_frames: raise IOError else: return self.ts - + def _read_frame(self, frame): self.ts.frame = frame @@ -62,6 +61,7 @@ def _reopen(self): class AmazingReader(SingleFrameReader): format = 'Amazing' + # have to hack this in to get the base class to "work" def _read_first_frame(self): self.n_atoms = 10 @@ -71,17 +71,18 @@ def _read_first_frame(self): class _TestReader(object): """Basic API readers""" + def setUp(self): self.reader = self.readerclass('test.txt') self.ts = self.reader.ts - + def test_required_attributes(self): """Test that Reader has the required attributes""" for attr in ['filename', 'n_atoms', 'n_frames', 'ts', 'units', 'format']: assert_equal(hasattr(self.reader, attr), True, "Missing attr: {0}".format(attr)) - + def test_iter(self): l = [ts for ts in self.reader] @@ -122,7 +123,7 @@ class _Multi(_TestReader): n_atoms = 10 readerclass = AmazingMultiFrameReader reference = np.arange(10) - + class TestMultiFrameReader(_Multi): def _check_slice(self, start, stop, step): @@ -131,56 +132,44 @@ def _check_slice(self, start, stop, step): ref = self.reference[start:stop:step] assert_equal(res, ref) - + def test_slices(self): for start, stop, step in [ - (None, None, None), # blank slice - (None, 5, None), # set end point - (2, None, None), # set start point - (2, 5, None), # start & end - (None, None, 2), # set skip - (None, None, -1), # backwards skip - (0, 10, 1), - (0, 10, 2), - (None, 20, None), # end beyond real end - (None, 20, 2), # with skip - (0, 5, 2), - (5, None, -1), - (None, 5, -1), + (None, None, None), # blank slice + (None, 5, None), # set end point + (2, None, None), # set start point + (2, 5, None), # start & end + (None, None, 2), # set skip + (None, None, -1), # backwards skip + (0, 10, 1), + (0, 10, 2), + (None, 20, None), # end beyond real end + (None, 20, 2), # with skip + (0, 5, 2), + (5, None, -1), + (None, 5, -1), + (100, 10, 1), + (-10, None, 1), + (100, None, -1), # beyond real end + (100, 5, -20), + (5, 1, 1), # Stop less than start + (1, 5, -1), # Stop less than start + (-100, None, None), + (100, None, None), # Outside of range of trajectory + (-2, 10, -2) ]: yield self._check_slice, start, stop, step - def test_slice_IE_1a(self): - """Stop less than start""" - def sl(): - return list(self.reader[5:1:1]) - assert_raises(IndexError, sl) - - def test_slice_IE_1b(self): - """Stop less than start""" - def sl(): - return list(self.reader[1:5:-1]) - assert_raises(IndexError, sl) - - def test_slice_IE_2(self): - """Outside of range of trajectory""" - def sl(): - return list(self.reader[100:]) - assert_raises(IndexError, sl) - - def test_slice_IE_3(self): - def sl(): - return list(self.reader[-100:]) - assert_raises(IndexError, sl) - def test_slice_VE_1(self): def sl(): return list(self.reader[::0]) + assert_raises(ValueError, sl) def test_slice_TE_1(self): def sl(): return list(self.reader[1.2:2.5:0.1]) + assert_raises(TypeError, sl) def _check_getitem(self, sl): @@ -200,16 +189,18 @@ def test_getitem_list_ints(self): [0, 1, 1, 1, 0, 0, 2, 3, 4], np.array([0, 1, 1, 1, 0, 0, 2, 3, 4]), ): - yield self._check_getitem, sl + yield self._check_getitem, sl def test_list_TE(self): def sl(): return list(self.reader[[0, 'a', 5, 6]]) + assert_raises(TypeError, sl) def test_array_TE(self): def sl(): return list(self.reader[np.array([1.2, 3.4, 5.6])]) + assert_raises(TypeError, sl) def test_bool_slice(self): @@ -277,4 +268,3 @@ def test_rewind(self): def test_read_frame(self): assert_raises(IndexError, self.reader._read_frame, 1) - diff --git a/testsuite/MDAnalysisTests/coordinates/test_trz.py b/testsuite/MDAnalysisTests/coordinates/test_trz.py index 951d6bf0706..70ec9a4e20e 100644 --- a/testsuite/MDAnalysisTests/coordinates/test_trz.py +++ b/testsuite/MDAnalysisTests/coordinates/test_trz.py @@ -1,6 +1,6 @@ +from six.moves import zip import MDAnalysis as mda import os -from six.moves import zip from numpy.testing import (assert_equal, assert_array_almost_equal, assert_almost_equal, assert_raises)