Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump up auxiliary coverage #2570

Merged
merged 40 commits into from
Mar 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
7af3352
Merge remote-tracking branch 'upstream/develop' into develop
RMeli Aug 7, 2019
51624f3
Merge remote-tracking branch 'upstream/develop' into develop
RMeli Aug 9, 2019
fa7777e
Merge remote-tracking branch 'upstream/develop' into develop
RMeli Aug 13, 2019
94ac6cc
Merge remote-tracking branch 'upstream/develop' into develop
RMeli Aug 20, 2019
80370af
Merge remote-tracking branch 'upstream/develop' into develop
RMeli Sep 5, 2019
36fa2ea
Merge remote-tracking branch 'upstream/develop' into develop
RMeli Sep 10, 2019
5111103
Merge remote-tracking branch 'upstream/develop' into develop
RMeli Oct 2, 2019
ad0c149
Merge remote-tracking branch 'upstream/develop' into develop
RMeli Oct 3, 2019
def7c14
Merge remote-tracking branch 'upstream/develop' into develop
RMeli Oct 16, 2019
2d693e3
Merge remote-tracking branch 'upstream/develop' into develop
RMeli Oct 30, 2019
f7d5bc6
Merge remote-tracking branch 'upstream/develop' into develop
RMeli Nov 21, 2019
64bcae5
Merge remote-tracking branch 'upstream/develop' into develop
RMeli Nov 28, 2019
2e2561e
Merge remote-tracking branch 'upstream/develop' into develop
RMeli Dec 23, 2019
2184e2b
Merge remote-tracking branch 'upstream/develop' into develop
RMeli Jan 14, 2020
de7afcc
Merge remote-tracking branch 'upstream/develop' into develop
RMeli Jan 16, 2020
ff4ed8d
Merge remote-tracking branch 'upstream/develop' into develop
RMeli Jan 17, 2020
c515e89
Merge remote-tracking branch 'upstream/develop' into develop
RMeli Jan 17, 2020
7d27138
Merge remote-tracking branch 'upstream/develop' into develop
RMeli Jan 18, 2020
3c35af0
Merge remote-tracking branch 'upstream/develop' into develop
RMeli Jan 21, 2020
22def6a
Merge remote-tracking branch 'upstream/develop' into develop
RMeli Jan 23, 2020
93413dc
Merge remote-tracking branch 'upstream/develop' into develop
RMeli Jan 24, 2020
8c5dc00
Merge remote-tracking branch 'upstream/develop' into develop
RMeli Feb 1, 2020
ad1766e
Merge remote-tracking branch 'upstream/develop' into develop
RMeli Feb 4, 2020
65e4d66
Merge remote-tracking branch 'upstream/develop' into develop
RMeli Feb 4, 2020
549c1a2
Merge remote-tracking branch 'upstream/develop' into develop
RMeli Feb 6, 2020
f527e62
Merge remote-tracking branch 'upstream/develop' into develop
RMeli Feb 9, 2020
4d5f7de
Merge remote-tracking branch 'upstream/develop' into develop
RMeli Feb 9, 2020
d7eda78
Merge remote-tracking branch 'upstream/develop' into develop
RMeli Feb 13, 2020
ccd77e9
Merge remote-tracking branch 'upstream/develop' into develop
RMeli Feb 15, 2020
7546c3e
Merge remote-tracking branch 'upstream/develop' into develop
RMeli Feb 16, 2020
af65b17
Merge remote-tracking branch 'upstream/develop' into develop
RMeli Feb 26, 2020
5944b83
Merge remote-tracking branch 'upstream/develop' into develop
RMeli Feb 27, 2020
14bf111
bump auxreader core coverage
RMeli Feb 27, 2020
240ccec
add more test on failures
RMeli Feb 27, 2020
c46bf91
test XVGStep failures
RMeli Feb 27, 2020
eff4e01
remove unused module
RMeli Feb 29, 2020
640ce81
Merge remote-tracking branch 'upstream/develop' into develop
RMeli Feb 29, 2020
f25aa71
fix test
RMeli Mar 1, 2020
4d639f9
Merge remote-tracking branch 'upstream/develop' into develop
RMeli Mar 3, 2020
952a3e2
Merge branch 'develop' into feat/auxreader-cov
RMeli Mar 3, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package/MDAnalysis/auxiliary/XVG.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
"""
from __future__ import absolute_import

from six.moves import range
from six import raise_from

import numbers
Expand All @@ -77,6 +76,7 @@
from . import base
from ..lib.util import anyopen


def uncomment(lines):
""" Remove comments from lines in an .xvg file

Expand Down
20 changes: 19 additions & 1 deletion testsuite/MDAnalysisTests/auxiliary/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,11 @@ def test_time_selector(self, ref):
for i, val in enumerate(reader):
assert val.time == ref.select_time_ref[i], "time for step {} does not match".format(i)

def test_time_non_constant_dt(self, reader):
reader.constant_dt = False
with pytest.raises(ValueError, match="If dt is not constant, must have a valid time selector"):
reader.time

def test_time_selector_manual(self, ref):
reader = ref.reader(ref.testdata,
time_selector = ref.time_selector)
Expand Down Expand Up @@ -367,7 +372,7 @@ def test_step_to_frame_out_of_bounds(self, reader, ref):
def test_step_to_frame_no_time_diff(self, reader, ref):

ts = mda.coordinates.base.Timestep(0, dt=ref.dt)

for idx in range(reader.n_steps):

assert reader.step_to_frame(idx, ts) == idx
Expand All @@ -385,6 +390,19 @@ def test_step_to_frame_time_diff(self, reader, ref):
assert frame == idx
np.testing.assert_almost_equal(time_diff, idx * 0.1)

def test_go_to_step_fail(self, reader):

with pytest.raises(ValueError, match="Step index [0-9]* is not valid for auxiliary"):
reader._go_to_step(reader.n_steps)

@pytest.mark.parametrize("constant", [True, False])
def test_set_constant_dt(self, reader, constant):

reader.constant_dt = constant

assert reader.constant_dt == constant


def assert_auxstep_equal(A, B):
if not isinstance(A, mda.auxiliary.base.AuxStep):
raise AssertionError('A is not of type AuxStep')
Expand Down
43 changes: 43 additions & 0 deletions testsuite/MDAnalysisTests/auxiliary/test_core.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# -*- Mode: python; tab-width: 4; indent-tabs-mode:nil; coding:utf-8 -*-
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 fileencoding=utf-8
#
# MDAnalysis --- https://www.mdanalysis.org
# Copyright (c) 2006-2017 The MDAnalysis Development Team and contributors
# (see the file AUTHORS for the full list of names)
#
# Released under the GNU Public Licence, v2 or any higher version
#
# Please cite your use of MDAnalysis in published work:
#
# R. J. Gowers, M. Linke, J. Barnoud, T. J. E. Reddy, M. N. Melo, S. L. Seyler,
# D. L. Dotson, J. Domanski, S. Buchoux, I. M. Kenney, and O. Beckstein.
# MDAnalysis: A Python package for the rapid analysis of molecular dynamics
# simulations. In S. Benthall and S. Rostrup editors, Proceedings of the 15th
# Python in Science Conference, pages 102-109, Austin, TX, 2016. SciPy.
# doi: 10.25080/majora-629e541a-00e
#
# N. Michaud-Agrawal, E. J. Denning, T. B. Woolf, and O. Beckstein.
# MDAnalysis: A Toolkit for the Analysis of Molecular Dynamics Simulations.
# J. Comput. Chem. 32 (2011), 2319--2327, doi:10.1002/jcc.21787
#

from __future__ import absolute_import

import MDAnalysis as mda

import pytest


def test_get_auxreader_for_none():
with pytest.raises(ValueError, match="Must provide either auxdata or format"):
mda.auxiliary.core.get_auxreader_for()


def test_get_auxreader_for_wrong_auxdata():
with pytest.raises(ValueError, match="Unknown auxiliary data format for auxdata:"):
mda.auxiliary.core.get_auxreader_for(auxdata="test.none")


def test_get_auxreader_for_wrong_format():
with pytest.raises(ValueError, match="Unknown auxiliary data format"):
mda.auxiliary.core.get_auxreader_for(format="none")
24 changes: 24 additions & 0 deletions testsuite/MDAnalysisTests/auxiliary/test_xvg.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

from MDAnalysisTests.datafiles import AUX_XVG, XVG_BAD_NCOL, XVG_BZ2
from MDAnalysisTests.auxiliary.base import (BaseAuxReaderTest, BaseAuxReference)
from MDAnalysis.auxiliary.XVG import XVGStep


class XVGReference(BaseAuxReference):
Expand All @@ -52,6 +53,29 @@ def __init__(self):
self.select_data_ref = [self.format_data([2*i, 2**i]) for i in range(self.n_steps)]


class TestXVGStep():

@staticmethod
@pytest.fixture()
def step():
return XVGStep()

def test_select_time_none(self, step):

st = step._select_time(None)

assert st is None

def test_select_time_invalid_index(self, step):
with pytest.raises(ValueError, match="Time selector must be single index"):
step._select_time([0])

def test_select_data_none(self, step):

st = step._select_data(None)

assert st is None

class TestXVGReader(BaseAuxReaderTest):
@staticmethod
@pytest.fixture()
Expand Down