Skip to content

Commit

Permalink
Merge branch 'develop' into issue-3386
Browse files Browse the repository at this point in the history
  • Loading branch information
IAlibay committed Jan 21, 2022
2 parents 2fc179a + d593993 commit 9b7917d
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 21 deletions.
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- job: Windows
condition: and(succeeded(), ne(variables['Build.SourceBranch'], 'refs/heads/master')) # skip for PR merges
pool:
vmImage: 'VS2017-Win2016'
vmImage: 'windows-2019'
variables:
MPLBACKEND: agg
strategy:
Expand Down
3 changes: 3 additions & 0 deletions testsuite/MDAnalysisTests/lib/test_augment.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# MDAnalysis: A Toolkit for the Analysis of Molecular Dynamics Simulations.
# J. Comput. Chem. 32 (2011), 2319--2327, doi:10.1002/jcc.21787

import os
import pytest
import numpy as np
from numpy.testing import assert_almost_equal, assert_equal
Expand Down Expand Up @@ -67,6 +68,8 @@
)


@pytest.mark.xfail(os.name == "nt",
reason="see gh-3248")
@pytest.mark.parametrize('b', (
np.array([10, 10, 10, 90, 90, 90], dtype=np.float32),
np.array([10, 10, 10, 45, 60, 90], dtype=np.float32)
Expand Down
39 changes: 19 additions & 20 deletions testsuite/MDAnalysisTests/utils/test_streamio.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,18 +202,15 @@ def test_join(self, tmpdir, funcname="join"):
err_msg=("os.path.{0}() does not work with "
"NamedStream").format(funcname))

@pytest.mark.skipif(True, reason='See #1534]')
def test_expanduser_noexpansion_returns_NamedStream(self):
ns = self.create_NamedStream("de/zipferlack.txt") # no tilde ~ in name!
reference = ns
reference = ns.name
value = os.path.expanduser(ns)
assert_equal(value, reference,
err_msg=("os.path.expanduser() without '~' did not "
"return NamedStream --- weird!!"))

@pytest.mark.skipif(True, reason='See #1534')
@pytest.mark.skipif("HOME" not in os.environ, reason='It is needed')
@pytest.mark.xfail
def test_expandvars(self):
name = "${HOME}/stories/jabberwock.txt"
ns = self.create_NamedStream(name)
Expand All @@ -222,10 +219,9 @@ def test_expandvars(self):
assert_equal(value, reference,
err_msg="os.path.expandvars() did not expand HOME")

@pytest.mark.skipif(True, reason='See #1534')
def test_expandvars_noexpansion_returns_NamedStream(self):
ns = self.create_NamedStream() # no $VAR constructs
reference = ns
reference = ns.name
value = os.path.expandvars(ns)
assert_equal(value, reference,
err_msg=("os.path.expandvars() without '$VARS' did not "
Expand Down Expand Up @@ -261,8 +257,10 @@ class _StreamData(object):
}

def __init__(self):
self.buffers = {name: "".join(open(fn).readlines())
for name, fn in self.filenames.items()}
self.buffers = {}
for name, fn in self.filenames.items():
with open(fn) as filed:
self.buffers[name] = "".join(filed.readlines())
self.filenames['XYZ_PSF'] = u"bogus/path/mini.psf"
self.buffers['XYZ_PSF'] = u"""\
PSF CMAP
Expand Down Expand Up @@ -322,45 +320,46 @@ def as_NamedStream(self, name):
return util.NamedStream(self.as_StringIO(name), self.filenames[name])


streamData = _StreamData()
del _StreamData
@pytest.fixture(scope='module')
def streamData():
return _StreamData()


# possibly add tests to individual readers instead?
class TestStreamIO(RefAdKSmall):
def test_PrimitivePDBReader(self):
def test_PrimitivePDBReader(self, streamData):
u = MDAnalysis.Universe(streamData.as_NamedStream('PDB'))
assert_equal(u.atoms.n_atoms, self.ref_n_atoms)

def test_PDBReader(self):
def test_PDBReader(self, streamData):
try:
u = MDAnalysis.Universe(streamData.as_NamedStream('PDB'))
except Exception as err:
raise pytest.fail("StreamIO not supported:\n>>>>> {0}".format(err))
assert_equal(u.atoms.n_atoms, self.ref_n_atoms)

def test_CRDReader(self):
def test_CRDReader(self, streamData):
u = MDAnalysis.Universe(streamData.as_NamedStream('CRD'))
assert_equal(u.atoms.n_atoms, self.ref_n_atoms)

def test_PSFParser(self):
def test_PSFParser(self, streamData):
u = MDAnalysis.Universe(streamData.as_NamedStream('PSF'))
assert_equal(u.atoms.n_atoms, self.ref_n_atoms)

def test_PSF_CRD(self):
def test_PSF_CRD(self, streamData):
u = MDAnalysis.Universe(streamData.as_NamedStream('PSF'),
streamData.as_NamedStream('CRD'))
assert_equal(u.atoms.n_atoms, self.ref_n_atoms)

def test_PQRReader(self):
def test_PQRReader(self, streamData):
u = MDAnalysis.Universe(streamData.as_NamedStream('PQR'))
assert_equal(u.atoms.n_atoms, self.ref_n_atoms)
assert_almost_equal(u.atoms.total_charge(), self.ref_charmm_totalcharge, 3,
"Total charge (in CHARMM) does not match expected value.")
assert_almost_equal(u.atoms.select_atoms('name H').charges, self.ref_charmm_Hcharges, 3,
"Charges for H atoms do not match.")

def test_PDBQTReader(self):
def test_PDBQTReader(self, streamData):
u = MDAnalysis.Universe(streamData.as_NamedStream('PDBQT'))
sel = u.select_atoms('backbone')
assert_equal(sel.n_atoms, 796)
Expand All @@ -369,7 +368,7 @@ def test_PDBQTReader(self):
sel = u.select_atoms('segid B')
assert_equal(sel.n_atoms, 896, "failed to select segment B")

def test_GROReader(self):
def test_GROReader(self, streamData):
u = MDAnalysis.Universe(streamData.as_NamedStream('GRO'))
assert_equal(u.atoms.n_atoms, 6)
assert_almost_equal(u.atoms[3].position,
Expand All @@ -379,14 +378,14 @@ def test_GROReader(self):
10. * np.array([0.2519, 0.3140, -0.1734]), 3, # manually convert nm/ps -> A/ps
err_msg="wrong velocity for water 2 OW")

def test_MOL2Reader(self):
def test_MOL2Reader(self, streamData):
u = MDAnalysis.Universe(streamData.as_NamedStream('MOL2'))
assert_equal(len(u.atoms), 49)
assert_equal(u.trajectory.n_frames, 200)
u.trajectory[199]
assert_array_almost_equal(u.atoms.positions[0], [1.7240, 11.2730, 14.1200])

def test_XYZReader(self):
def test_XYZReader(self, streamData):
u = MDAnalysis.Universe(streamData.as_NamedStream('XYZ_PSF'),
streamData.as_NamedStream('XYZ'))
assert_equal(len(u.atoms), 8)
Expand Down
9 changes: 9 additions & 0 deletions testsuite/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ filterwarnings=
ignore:`np.*` is a deprecated alias for the builtin:DeprecationWarning:networkx.*:
error:Creating an ndarray from ragged nested sequences
error:invalid escape sequence \\:DeprecationWarning
# Ignore frequent errors popping up in our tests
# Elements
ignore:Element information:UserWarning
# Mass
ignore:Failed to guess the mass:UserWarning
# Coordinates
ignore:No coordinate reader found:UserWarning
# NamedStream warnings
ignore:Constructed NamedStream:RuntimeWarning

# Settings to test for warnings we throw
# [tool:pytest]
Expand Down

0 comments on commit 9b7917d

Please sign in to comment.