diff --git a/.travis.yml b/.travis.yml index e853823a..91b2b513 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,8 +27,8 @@ env: matrix: # use ci-helper's PACKAGENAME_VERSION magic to pin the 'gromacs' package - - GROMACS_VERSION=4.6.5 PYTHON_VERSION=2.7 - - GROMACS_VERSION=2019.1 PYTHON_VERSION=2.7 + - GROMACS_VERSION=4.6.5 PYTHON_VERSION=2.7 NUMPY_VERSION=1.16 + - GROMACS_VERSION=2019.1 PYTHON_VERSION=2.7 NUMPY_VERSION=1.16 - GROMACS_VERSION=4.6.5 PYTHON_VERSION=3.6 - GROMACS_VERSION=2018.6 PYTHON_VERSION=3.6 - GROMACS_VERSION=2019.1 PYTHON_VERSION=3.6 @@ -46,7 +46,7 @@ matrix: - os: osx env: GROMACS_VERSION=4.6.5 PYTHON_VERSION=3.6 - os: osx - env: GROMACS_VERSION=2019.1 PYTHON_VERSION=2.7 + env: GROMACS_VERSION=2019.1 PYTHON_VERSION=2.7 NUMPY_VERSION=1.16 - os: osx env: GROMACS_VERSION=2019.1 PYTHON_VERSION=3.6 diff --git a/CHANGES b/CHANGES index 5380df07..037b5f81 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,12 @@ CHANGELOG for GromacsWrapper ============================== +2019-xx-xx 0.8.1 +orbeckst + +* fixed: xpm.to_df() used outdated convert_objects() +* fixed: gw-forcefield.py use print() function for Py 2/3 compatibility + 2019-04-30 0.8.0 richardjgowers, theavey, andrejberg, orbeckst diff --git a/gromacs/fileformats/xpm.py b/gromacs/fileformats/xpm.py index 14c26f7a..2a0ba6fc 100644 --- a/gromacs/fileformats/xpm.py +++ b/gromacs/fileformats/xpm.py @@ -154,16 +154,17 @@ def __init__(self, filename=None, **kwargs): def to_df(self): - import pandas as _pd + import pandas as pd # Add Time to the data as column data = numpy.vstack((self.xvalues, self.array.T)).T # Column names are resids - df = _pd.DataFrame(data, columns=["Time"]+ list(self.yvalues)) + df = pd.DataFrame(data, columns=["Time"]+ list(self.yvalues)) # Converts Time to a numeric type - return df.convert_objects(convert_numeric='force') + df['Time'] = pd.to_numeric(df['Time']) + return df @property def array(self): diff --git a/scripts/gw-forcefield.py b/scripts/gw-forcefield.py index 33a0ebe4..e7ec40d6 100755 --- a/scripts/gw-forcefield.py +++ b/scripts/gw-forcefield.py @@ -1,3 +1,4 @@ +from __future__ import print_function from gromacs.fileformats import TOP import numpy as np @@ -50,7 +51,7 @@ def scale_dihedrals(mol, dihedrals): new_dihedrals[key] = dt break - print new_dihedrals + print(new_dihedrals) return new_dihedrals.values() @@ -73,7 +74,7 @@ def scale_impropers(mol, impropers): for i, imt in enumerate(impropers[key]): new_impropers[key] = imt break - print new_impropers + print(new_impropers) return new_impropers.values() diff --git a/tests/fileformats/test_xpm.py b/tests/fileformats/test_xpm.py index 15100cf2..1db24a0c 100644 --- a/tests/fileformats/test_xpm.py +++ b/tests/fileformats/test_xpm.py @@ -18,6 +18,10 @@ def ssfile(): def xpm(ssfile): return XPM(filename=ssfile) +@pytest.fixture +def xpm_df(xpm): + return xpm.to_df() + class TestXPM(object): def _run_tests(self, x): assert_equal(x.array.shape, (500, 769)) @@ -36,7 +40,10 @@ def test_read(self, ssfile): def test_reversed_by_default(self, xpm): assert xpm.reverse - def test_to_pd(self, xpm): - df = xpm.to_df() - assert_equal(df.shape, (500, 770)) + def test_to_pd(self, xpm_df): + assert_equal(xpm_df.shape, (500, 770)) + def test_to_pd_types(self, xpm_df): + time = xpm_df['Time'] + assert len(time) == 500 + assert time.dtype == np.dtype("int64") # true for this file