Skip to content

Commit

Permalink
Merge branch 'develop' into feature-ukwargs
Browse files Browse the repository at this point in the history
  • Loading branch information
dotsdl committed Apr 3, 2016
2 parents 5ec58e8 + 7bd6b76 commit b5464e4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
21 changes: 20 additions & 1 deletion src/mdsynthesis/tests/test_treants.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from datreant.core.tests.test_treants import TestTreant

import MDAnalysis as mda
from MDAnalysisTests.datafiles import PDB, GRO, XTC
from MDAnalysisTests.datafiles import PDB, GRO, XTC, PSF


class TestSim(TestTreant):
Expand Down Expand Up @@ -55,6 +55,25 @@ def test_set_universe(self, treant):
assert treant.udef.topology == GRO
assert treant.udef.trajectory == XTC

def test_set_universe_only_topology(self, treant):
"""Test setting the Universe to a topology-only universe"""
u = mda.Universe(PSF)

treant.universe = u

assert treant.universe.filename == PSF
assert treant.udef.topology == PSF
assert treant.udef.trajectory is None

def test_set_universe_chainreader(self, treant):
"""Test setting the Universe to multiple file trajectory (chain)"""
u = mda.Universe(GRO, [XTC, XTC])

treant.universe = u

assert treant.udef.topology == GRO
assert treant.udef.trajectory == [XTC, XTC]

def test_add_univese_typeerror(self, treant):
"""Test checking of what is passed to setter"""
with pytest.raises(TypeError):
Expand Down
10 changes: 5 additions & 5 deletions src/mdsynthesis/treants.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ def universe(self, universe):
type(universe)))
else:
self.udef.topology = universe.filename
try:
traj = universe.trajectory.filename
try: # ChainReader?
traj = universe.trajectory.filenames
except AttributeError:
try:
traj = universe.trajectory.filenames
except AttributeError:
try: # Reader?
traj = universe.trajectory.filename
except AttributeError: # Only topology
traj = None

self.udef.trajectory = traj
Expand Down

0 comments on commit b5464e4

Please sign in to comment.