Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
BFedder committed Jun 29, 2022
2 parents bf89e03 + 84bd117 commit 9632971
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions panedr/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ classifier =
test =
six
pytest
pandas =
pandas
17 changes: 17 additions & 0 deletions tests/test_edr.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@
EDR_Data = namedtuple('EDR_Data', ['df', 'xvgdata', 'xvgtime', 'xvgnames',
'xvgprec', 'edrfile', 'xvgfile'])


def test_failed_import(monkeypatch):
# Putting this test first to avoid datafiles already being loaded
errmsg = "ERROR --- pandas was not found!"
monkeypatch.setitem(sys.modules, 'pandas', None)
with pytest.raises(ImportError, match=errmsg):
panedr.edr_to_df(EDR)


@pytest.fixture(scope='module',
params=[(EDR, EDR_XVG),
(EDR_IRREGULAR, EDR_IRREGULAR_XVG),
Expand Down Expand Up @@ -146,6 +155,14 @@ def _assert_progress_range(self, progress, dt, start, stop, step):
assert ref_line == progress_line


def test_edr_to_dict_matches_edr_to_df():
array_dict = panedr.edr_to_dict(EDR)
ref_df = panedr.edr_to_df(EDR)
array_df = pandas.DataFrame.from_dict(array_dict).set_index(
"Time", drop=False)
assert array_df.equals(ref_df)


def read_xvg(path):
"""
Reads XVG file, returning the data, names, and precision.
Expand Down

0 comments on commit 9632971

Please sign in to comment.