Skip to content

Commit

Permalink
Remove Timestep code path for ParmedConverter (#3172)
Browse files Browse the repository at this point in the history
Towards #3031 

# Work done in this PR
* Removes the non-working code path for timestep handling in the ParmedConverter
  • Loading branch information
lilyminium authored Apr 3, 2021
1 parent c6f1a5a commit 1522653
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
2 changes: 2 additions & 0 deletions package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ Changes
* Maximum pinned versions in setup.py removed for python 3.6+ (PR #3139)

Deprecations
* ParmEdConverter no longer accepts Timestep objects at all
(Issue #3031, PR #3172)
* NCDFWriter `scale_factor` writing will change in version 2.0 to
better match AMBER outputs (Issue #2327)
* Deprecated using the last letter of the segid as the
Expand Down
6 changes: 4 additions & 2 deletions package/MDAnalysis/coordinates/ParmEd.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
import functools
import itertools
import warnings
from six import raise_from

from . import base
from ..topology.tables import SYMB2Z
Expand Down Expand Up @@ -174,9 +175,10 @@ def convert(self, obj):
ag_or_ts = obj.atoms
except AttributeError:
if isinstance(obj, base.Timestep):
ag_or_ts = obj.copy()
raise ValueError("Writing Timesteps to ParmEd "
"objects is not supported")
else:
raise_from(TypeError("No Timestep found in obj argument"), None)
raise_from(TypeError("No atoms found in obj argument"), None)

# Check for topology information
missing_topology = []
Expand Down
15 changes: 15 additions & 0 deletions testsuite/MDAnalysisTests/coordinates/test_parmed.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

from MDAnalysisTests.coordinates.base import _SingleFrameReader
from MDAnalysisTests.coordinates.reference import RefAdKSmall
from MDAnalysis.coordinates.ParmEd import ParmEdConverter

from MDAnalysisTests.datafiles import (
GRO,
Expand Down Expand Up @@ -288,3 +289,17 @@ class TestParmEdConverterPDB(BaseTestParmEdConverter):
def test_equivalent_coordinates(self, ref, output):
assert_almost_equal(ref.coordinates, output.coordinates, decimal=3)


def test_pass_ts_error():
u = mda.Universe(PDB_small)
err = "Writing Timesteps to ParmEd objects is not supported"
with pytest.raises(ValueError, match=err):
c = ParmEdConverter()
c.convert(u.trajectory.ts)


def test_incorrect_object_passed_typeerror():
err = "No atoms found in obj argument"
with pytest.raises(TypeError, match=err):
c = ParmEdConverter()
c.convert("we still don't support emojis :(")

0 comments on commit 1522653

Please sign in to comment.