Skip to content

Commit

Permalink
Merge pull request #179 from Becksteinlab/fix-recent-failures
Browse files Browse the repository at this point in the history
various fixes due to upstream updates
  • Loading branch information
orbeckst authored Jul 29, 2020
2 parents 79e5594 + 3ab9679 commit aef6357
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 11 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
6 changes: 6 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 4 additions & 3 deletions gromacs/fileformats/xpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
5 changes: 3 additions & 2 deletions scripts/gw-forcefield.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function

from gromacs.fileformats import TOP
import numpy as np
Expand Down Expand Up @@ -50,7 +51,7 @@ def scale_dihedrals(mol, dihedrals):
new_dihedrals[key] = dt
break

print new_dihedrals
print(new_dihedrals)
return new_dihedrals.values()


Expand All @@ -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()


Expand Down
13 changes: 10 additions & 3 deletions tests/fileformats/test_xpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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

0 comments on commit aef6357

Please sign in to comment.