pyedr
Advanced tools
+16
-4
| Metadata-Version: 2.1 | ||
| Name: pyedr | ||
| Version: 0.6.0 | ||
| Version: 0.7.0 | ||
| Summary: Read and manipulate Gromacs energy files | ||
@@ -46,2 +46,4 @@ Home-page: https://github.com/MDAnalysis/panedr | ||
| in a nested list | ||
| - ``get_unit_dictionary``: Returns a dictionary that holds the units of each | ||
| energy term found in the EDR file. | ||
@@ -54,6 +56,8 @@ | ||
| and returns its contents as a pandas_ dataframe. Panedr exposes the | ||
| following function: | ||
| following functions: | ||
| - ``edr_to_df``: which gets the path to an EDR file and returns a | ||
| pandas DataFrame, | ||
| pandas DataFrame. | ||
| - ``get_unit_dictionary``: Returns a dictionary that holds the units of each | ||
| energy term found in the EDR file. | ||
@@ -82,3 +86,7 @@ | ||
| # Get the units of the EDR entries | ||
| unit_dict = pyedr.get_unit_dictionary(path) | ||
| unit_dict["Temperature"] # returns "K" | ||
| Using ``panedr``: | ||
@@ -102,3 +110,7 @@ | ||
| # Get the units of the EDR entries | ||
| unit_dict = panedr.get_unit_dictionary(path) | ||
| unit_dict["Temperature"] # returns "K" | ||
| Install | ||
@@ -111,3 +123,3 @@ ------- | ||
| pip install pyedr | ||
| pip install pyedr | ||
@@ -114,0 +126,0 @@ # installing panedr automatically installs pyedr |
@@ -1,1 +0,1 @@ | ||
| {"git_version": "ccfdc89", "is_release": false} | ||
| {"git_version": "a66de99", "is_release": false} |
| Metadata-Version: 2.1 | ||
| Name: pyedr | ||
| Version: 0.6.0 | ||
| Version: 0.7.0 | ||
| Summary: Read and manipulate Gromacs energy files | ||
@@ -46,2 +46,4 @@ Home-page: https://github.com/MDAnalysis/panedr | ||
| in a nested list | ||
| - ``get_unit_dictionary``: Returns a dictionary that holds the units of each | ||
| energy term found in the EDR file. | ||
@@ -54,6 +56,8 @@ | ||
| and returns its contents as a pandas_ dataframe. Panedr exposes the | ||
| following function: | ||
| following functions: | ||
| - ``edr_to_df``: which gets the path to an EDR file and returns a | ||
| pandas DataFrame, | ||
| pandas DataFrame. | ||
| - ``get_unit_dictionary``: Returns a dictionary that holds the units of each | ||
| energy term found in the EDR file. | ||
@@ -82,3 +86,7 @@ | ||
| # Get the units of the EDR entries | ||
| unit_dict = pyedr.get_unit_dictionary(path) | ||
| unit_dict["Temperature"] # returns "K" | ||
| Using ``panedr``: | ||
@@ -102,3 +110,7 @@ | ||
| # Get the units of the EDR entries | ||
| unit_dict = panedr.get_unit_dictionary(path) | ||
| unit_dict["Temperature"] # returns "K" | ||
| Install | ||
@@ -111,3 +123,3 @@ ------- | ||
| pip install pyedr | ||
| pip install pyedr | ||
@@ -114,0 +126,0 @@ # installing panedr automatically installs pyedr |
| # -*- 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 |
+26
-2
@@ -83,3 +83,3 @@ #-*- coding:utf-8 -*- | ||
| __all__ = ['edr_to_dict', 'read_edr'] | ||
| __all__ = ['edr_to_dict', 'read_edr', 'get_unit_dictionary'] | ||
@@ -413,3 +413,5 @@ class EDRFile(object): | ||
| times_type = List[float] | ||
| read_edr_return_type = Tuple[all_energies_type, all_names_type, times_type] | ||
| read_edr_return_type = Tuple[all_energies_type, | ||
| all_names_type, | ||
| times_type] | ||
@@ -469,2 +471,24 @@ | ||
| def get_unit_dictionary(path: str) -> Dict[str, str]: | ||
| """Creates an EDRFile object which executes the :func:`do_enxnms` | ||
| method. This reads the names and units of the EDR data, which is returned | ||
| as a dictionary mapping column names (str) to unit names (str). | ||
| Parameters | ||
| ---------- | ||
| path : str | ||
| path to EDR file to be read | ||
| Returns | ||
| ------- | ||
| unit_dict: Dict[str, str] | ||
| A dictionary mapping the term names to their units. | ||
| """ | ||
| edr_file = EDRFile(str(path)) | ||
| unit_dict = {'Time': "ps"} | ||
| for nm in edr_file.nms: | ||
| unit_dict[nm.name] = nm.unit | ||
| return unit_dict | ||
| def edr_to_dict(path: str, verbose: bool = False) -> Dict[str, np.ndarray]: | ||
@@ -471,0 +495,0 @@ """Calls :func:`read_edr` and packs its return values into a dictionary |
@@ -33,10 +33,14 @@ #-*- coding:utf-8 -*- | ||
| EDR_XVG = resource_filename(__name__, 'data/cat.xvg') | ||
| EDR_UNITS = resource_filename(__name__, 'data/cat_units.p') | ||
| EDR_IRREGULAR = resource_filename(__name__, 'data/irregular.edr') | ||
| EDR_IRREGULAR_XVG = resource_filename(__name__, 'data/irregular.xvg') | ||
| EDR_IRREG = resource_filename(__name__, 'data/irregular.edr') | ||
| EDR_IRREG_XVG = resource_filename(__name__, 'data/irregular.xvg') | ||
| EDR_IRREG_UNITS = resource_filename(__name__, 'data/irregular_units.p') | ||
| EDR_DOUBLE = resource_filename(__name__, 'data/double.edr') | ||
| EDR_DOUBLE_XVG = resource_filename(__name__, 'data/double.xvg') | ||
| EDR_DOUBLE_UNITS = resource_filename(__name__, 'data/double_units.p') | ||
| EDR_BLOCKS = resource_filename(__name__, 'data/blocks.edr') | ||
| EDR_BLOCKS_XVG = resource_filename(__name__, 'data/blocks.xvg') | ||
| EDR_BLOCKS_UNITS = resource_filename(__name__, 'data/blocks_units.p') |
+23
-13
@@ -13,2 +13,3 @@ #-*- coding: utf-8 -*- | ||
| import unittest | ||
| import pickle | ||
@@ -21,4 +22,5 @@ import pytest | ||
| 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 | ||
| ) | ||
@@ -33,22 +35,26 @@ | ||
| # 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) | ||
@@ -60,2 +66,3 @@ | ||
| """ | ||
| def test_output_type(self, edr): | ||
@@ -68,2 +75,5 @@ """ | ||
| def test_units(self, edr): | ||
| assert edr.edr_units == edr.true_units | ||
| def test_columns(self, edr): | ||
@@ -70,0 +80,0 @@ """ |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
38255
6.72%663
5.07%