Commit e05f0ea0 authored by peastman's avatar peastman
Browse files

Merge pull request #1094 from rmcgibbo/rmcgibbo-patch-2

Assorted windows / appveyor fixes. Mostly cosmetic.
parents 3924b168 23143e82
......@@ -41,11 +41,11 @@ script:
- # Run the testInstallation script
- python -m simtk.testInstallation
- # run all of the tests, making sure failures at this stage don't cause travis failures
- ctest -j2 -V || true
- ctest -j2 || true
- # get a list of all of the failed tests into this stupid ctest format
- python -c 'fn = "Testing/Temporary/LastTestsFailed.log"; import os; os.path.exists(fn) or exit(0); l = [line.split(":")[0] for line in open(fn)]; triplets = zip(l, l, [","]*len(l)); print "".join(",".join(t) for t in triplets)' > FailedTests.log
- # rerun all of the failed tests
- if [ -s FailedTests.log ]; then ctest -V -I FailedTests.log; fi;
- if [ -s Testing/Temporary/LastTestsFailed.log ]; then ctest -I FailedTests.log; fi;
- # run the python tests too
- cd python/tests
- pip install nose
......
......@@ -122,7 +122,10 @@ ELSE (APPLE AND (NOT PNACL))
IF (MSVC OR ANDROID OR PNACL)
SET(EXTRA_COMPILE_FLAGS)
IF (MSVC)
# Use warning level 2, not whatever warning level CMake picked.
STRING(REGEX REPLACE "/W[0-4]" "/W2" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
# Explicitly suppress warnings 4305 and 4244.
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4305 /wd4244")
ENDIF (MSVC)
ELSE (MSVC OR ANDROID OR PNACL)
SET(EXTRA_COMPILE_FLAGS "-msse2")
......
......@@ -35,11 +35,13 @@ install:
build: false
test_script:
- ctest && exit 0
- python -c "import os; fn = os.path.join('Testing', 'Temporary', 'LastTestsFailed.log'); os.path.exists(fn) or exit(0); l = [line.split(':')[0] for line in open(fn)]; triplets = zip(l, l, [',']*len(l)); print(''.join(','.join(t) for t in triplets))" > FailedTests.log
- ctest || exit 0
- python -c "import os; fn = os.path.join('Testing', 'Temporary', 'LastTestsFailed.log'); os.path.exists(fn) or exit(0); failed = [line.split(':')[0] for line in open(fn)]; print(','.join(x+','+x for x in failed))" > FailedTests.log
- ps: >
If (Test-Path "FailedTests.log") {
ctest -V -I FailedTests.log
If (Test-Path "Testing\\Temporary\\LastTestsFailed.log") {
cat Testing\\Temporary\\LastTestsFailed.log
cat FailedTests.log
ctest -I FailedTests.log
}
- cd python\tests
- nosetests -vv --processes=-1 --process-timeout=200
......
......@@ -4,11 +4,18 @@ from simtk.openmm.app import *
from simtk.openmm import *
from simtk.unit import *
import simtk.openmm.app.element as elem
try:
from scipy.io import netcdf
SCIPY_IMPORT_FAILED = False
except:
SCIPY_IMPORT_FAILED = True
def compareByElement(array1, array2, cmp):
for x, y in zip(array1, array2):
cmp(x, y)
class TestAmberInpcrdFile(unittest.TestCase):
"""Test the Amber inpcrd file parser"""
......@@ -24,14 +31,11 @@ class TestAmberInpcrdFile(unittest.TestCase):
compareByElement(inpcrd.boxVectors[0].value_in_unit(angstroms),
[30.2642725, 0.0, 0.0], cmp)
@unittest.skipIf(SCIPY_IMPORT_FAILED, "Scipy is not installed")
def test_NetCDF(self):
""" Test NetCDF restart file parsing """
cmp = self.assertAlmostEqual
try:
from scipy.io import netcdf
except ImportError:
print('Not testing NetCDF file parser... scipy cannot be found')
else:
inpcrd = AmberInpcrdFile('systems/amber.ncrst')
self.assertEqual(len(inpcrd.positions), 2101)
compareByElement(inpcrd.positions[0].value_in_unit(angstroms),
......
import os
import unittest
import tempfile
import numpy as np
from simtk.openmm import app
import simtk.openmm as mm
from simtk import unit
......@@ -24,17 +23,19 @@ class TestCheckpointReporter(unittest.TestCase):
self.simulation.step(1)
# get the current positions
positions = self.simulation.context.getState(getPositions=True).getPositions(asNumpy=True)._value
positions = self.simulation.context.getState(getPositions=True).getPositions()
# now set the positions into junk...
self.simulation.context.setPositions(np.random.random(positions.shape))
self.simulation.context.setPositions([mm.Vec3(0, 0, 0)] * len(positions))
# then reload the right positions from the checkpoint
file.close()
with open(file.name, 'rb') as f:
self.simulation.context.loadCheckpoint(f.read())
os.unlink(file.name)
newPositions = self.simulation.context.getState(getPositions=True).getPositions(asNumpy=True)._value
np.testing.assert_array_equal(positions, newPositions)
newPositions = self.simulation.context.getState(getPositions=True).getPositions()
self.assertSequenceEqual(positions, newPositions)
if __name__ == '__main__':
unittest.main()
import unittest
import numpy as np
from simtk.openmm import app
import simtk.openmm as mm
from simtk import unit
try:
import numpy as np
NUMPY_IMPORT_FAILED = False
except ImportError:
NUMPY_IMPORT_FAILED = True
@unittest.skipIf(NUMPY_IMPORT_FAILED, 'Numpy is not installed')
class TestNumpyCompatibility(unittest.TestCase):
def setUp(self):
......@@ -80,6 +85,8 @@ class TestNumpyCompatibility(unittest.TestCase):
self.assertEqual(size, 10)
np.testing.assert_array_almost_equal(energy, np.asarray(energy_out))
@unittest.skipIf(NUMPY_IMPORT_FAILED, 'Numpy is not installed')
class TestNumpyUnits(unittest.TestCase):
def setUp(self):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment