-
Notifications
You must be signed in to change notification settings - Fork 7
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
Make pyedr also return a dictionary of units #56
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
dcd7cfd
Made pyedr also return a dictionary of units
BFedder 8876a55
fixed edr_to_df expecting 3 instead of 4 values
BFedder 14f3c4b
actually fixed panedr tests
BFedder 8a9bfa9
panedr returns units, docstrings updated, typehints updated
BFedder fa82cf7
created own function for unit dict, mentioned in README
BFedder 780a93e
changed get_unit_dictionary's behaviour; PEP8
BFedder 6bd1e6e
more PEP8
BFedder c81aefb
fixed docstring of get_unit_dictionary
BFedder d078436
Corrected function annotation of edr_to_dict
BFedder 8e5f566
Update pyedr.py
BFedder File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from .panedr import edr_to_df, get_unit_dictionary | ||
import pbr.version | ||
__version__ = pbr.version.VersionInfo('panedr').release_string() | ||
del pbr | ||
|
||
from .panedr import edr_to_df |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from .pyedr import edr_to_dict, read_edr, get_unit_dictionary | ||
import pbr.version | ||
__version__ = pbr.version.VersionInfo('pyedr').release_string() | ||
del pbr | ||
|
||
from .pyedr import edr_to_dict, read_edr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,15 +10,17 @@ | |
import re | ||
import sys | ||
import unittest | ||
import pickle | ||
|
||
import pytest | ||
import numpy as np | ||
from numpy.testing import assert_allclose | ||
|
||
import pyedr | ||
from pyedr.tests.datafiles import ( | ||
EDR, EDR_XVG, EDR_IRREGULAR, EDR_IRREGULAR_XVG, | ||
EDR_DOUBLE, EDR_DOUBLE_XVG, EDR_BLOCKS, EDR_BLOCKS_XVG | ||
EDR, EDR_XVG, EDR_UNITS, EDR_IRREG, EDR_IRREG_XVG, | ||
EDR_IRREG_UNITS, EDR_DOUBLE, EDR_DOUBLE_XVG, EDR_DOUBLE_UNITS, | ||
EDR_BLOCKS, EDR_BLOCKS_XVG, EDR_BLOCKS_UNITS | ||
) | ||
|
||
|
||
|
@@ -28,39 +30,47 @@ | |
NDEC_PATTERN = re.compile(r'[\.eE]') | ||
|
||
# Data constants | ||
EDR_Data = namedtuple('EDR_Data', | ||
['edr_dict', 'xvgdata', 'xvgtime', 'xvgnames', | ||
'xvgcols', 'xvgprec', 'edrfile', 'xvgfile']) | ||
EDR_Data = namedtuple('EDR_Data', | ||
['edr_dict', 'edr_units', 'xvgdata', 'xvgtime', | ||
'xvgnames', 'xvgcols', 'xvgprec', 'true_units', | ||
'edrfile', 'xvgfile']) | ||
|
||
|
||
@pytest.fixture(scope='module', | ||
params=[(EDR, EDR_XVG), | ||
(EDR_IRREGULAR, EDR_IRREGULAR_XVG), | ||
(EDR_DOUBLE, EDR_DOUBLE_XVG), | ||
(EDR_BLOCKS, EDR_BLOCKS_XVG), | ||
(Path(EDR), EDR_XVG),]) | ||
params=[(EDR, EDR_XVG, EDR_UNITS), | ||
(EDR_IRREG, EDR_IRREG_XVG, EDR_IRREG_UNITS), | ||
(EDR_DOUBLE, EDR_DOUBLE_XVG, EDR_DOUBLE_UNITS), | ||
(EDR_BLOCKS, EDR_BLOCKS_XVG, EDR_BLOCKS_UNITS), | ||
(Path(EDR), EDR_XVG, EDR_UNITS), ]) | ||
def edr(request): | ||
edrfile, xvgfile = request.param | ||
edrfile, xvgfile, unitfile = request.param | ||
edr_dict = pyedr.edr_to_dict(edrfile) | ||
edr_units = pyedr.get_unit_dictionary(edrfile) | ||
xvgdata, xvgnames, xvgprec = read_xvg(xvgfile) | ||
with open(unitfile, "rb") as f: | ||
true_units = pickle.load(f) | ||
xvgtime = xvgdata[:, 0] | ||
xvgdata = xvgdata[:, 1:] | ||
xvgcols = np.insert(xvgnames, 0, u'Time') | ||
return EDR_Data(edr_dict, xvgdata, xvgtime, xvgnames, | ||
xvgcols, xvgprec, edrfile, xvgfile) | ||
return EDR_Data(edr_dict, edr_units, xvgdata, xvgtime, xvgnames, | ||
xvgcols, xvgprec, true_units, edrfile, xvgfile) | ||
|
||
|
||
class TestEdrToDict(object): | ||
""" | ||
Tests for :fun:`pyedr.edr_to_dict`. | ||
""" | ||
|
||
def test_output_type(self, edr): | ||
""" | ||
Test that the function returns a dictionary of ndarrays | ||
""" | ||
assert isinstance(edr.edr_dict, dict) | ||
assert isinstance(edr.edr_dict['Time'], np.ndarray) | ||
|
||
def test_units(self, edr): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The class name doesn't really match what this is doing, but I don't think it's worth being pedantic about it. |
||
assert edr.edr_units == edr.true_units | ||
|
||
def test_columns(self, edr): | ||
""" | ||
Test that the dictionary names match | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll let it go here because the likelihood is that no one was using these downstream, but arbitrarily renaming file object names like this is a breaking change, please avoid doing this.