Commit 23143e82 authored by Robert McGibbon's avatar Robert McGibbon
Browse files

Eliminate extra warning about overriding the warning level

Clean up

Fix OpenCL platform on low-end devices

Close file before deleting in TestAmberPrmtopFile.py

Close PDBx file before deleting to fix windows test failure in TestPDbxFile.py

Fix test checkpoint reporter close file before repoening

Add bytes typemap

Update appveyor.yml

Fix exit status

Supress 4305 and 4244 warnings

Print the last failed tests output

Make numpy optional in test

Improve scipy skip too

Refactor TestCheckpointReporter.py to not require numpy

test on the proper file

Remove annoying -V
parent 3924b168
...@@ -41,11 +41,11 @@ script: ...@@ -41,11 +41,11 @@ script:
- # Run the testInstallation script - # Run the testInstallation script
- python -m simtk.testInstallation - python -m simtk.testInstallation
- # run all of the tests, making sure failures at this stage don't cause travis failures - # 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 - # 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 - 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 - # 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 - # run the python tests too
- cd python/tests - cd python/tests
- pip install nose - pip install nose
......
#--------------------------------------------------- #---------------------------------------------------
# OpenMM # OpenMM
# #
# Creates OpenMM library. # Creates OpenMM library.
# #
...@@ -43,11 +43,11 @@ SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake_modules") ...@@ -43,11 +43,11 @@ SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake_modules")
# (cmake 2.4.7 is OK) # (cmake 2.4.7 is OK)
if(COMMAND cmake_policy) if(COMMAND cmake_policy)
if(CMAKE_MAJOR_VERSION GREATER 2 OR CMAKE_MINOR_VERSION GREATER 5) if(CMAKE_MAJOR_VERSION GREATER 2 OR CMAKE_MINOR_VERSION GREATER 5)
cmake_policy(SET CMP0003 NEW) cmake_policy(SET CMP0003 NEW)
cmake_policy(SET CMP0005 NEW) cmake_policy(SET CMP0005 NEW)
endif(CMAKE_MAJOR_VERSION GREATER 2 OR CMAKE_MINOR_VERSION GREATER 5) endif(CMAKE_MAJOR_VERSION GREATER 2 OR CMAKE_MINOR_VERSION GREATER 5)
if(CMAKE_MAJOR_VERSION GREATER 2 OR CMAKE_MINOR_VERSION GREATER 6 OR CMAKE_PATCH_VERSION GREATER 2) if(CMAKE_MAJOR_VERSION GREATER 2 OR CMAKE_MINOR_VERSION GREATER 6 OR CMAKE_PATCH_VERSION GREATER 2)
cmake_policy(SET CMP0011 NEW) cmake_policy(SET CMP0011 NEW)
endif(CMAKE_MAJOR_VERSION GREATER 2 OR CMAKE_MINOR_VERSION GREATER 6 OR CMAKE_PATCH_VERSION GREATER 2) endif(CMAKE_MAJOR_VERSION GREATER 2 OR CMAKE_MINOR_VERSION GREATER 6 OR CMAKE_PATCH_VERSION GREATER 2)
endif(COMMAND cmake_policy) endif(COMMAND cmake_policy)
...@@ -70,7 +70,7 @@ ENDIF (ANDROID) ...@@ -70,7 +70,7 @@ ENDIF (ANDROID)
# It seems that on linux and mac, everything is trying to be installed in /usr/local/openmm # It seems that on linux and mac, everything is trying to be installed in /usr/local/openmm
# But if every install target is prefixed with /openmm/, on Windows the install files # But if every install target is prefixed with /openmm/, on Windows the install files
# end up in C:/Program Files/OpenMM/openmm/ which is ugly. # end up in C:/Program Files/OpenMM/openmm/ which is ugly.
# Better to set CMAKE_INSTALL_PREFIX to /usr/local/openmm and leave /openmm/ off the # Better to set CMAKE_INSTALL_PREFIX to /usr/local/openmm and leave /openmm/ off the
# install target names. Plus, the user now has the opportunity to install into /usr/local/ # install target names. Plus, the user now has the opportunity to install into /usr/local/
# if she so chooses. --cmb # if she so chooses. --cmb
IF(${CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT}) IF(${CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT})
...@@ -122,7 +122,10 @@ ELSE (APPLE AND (NOT PNACL)) ...@@ -122,7 +122,10 @@ ELSE (APPLE AND (NOT PNACL))
IF (MSVC OR ANDROID OR PNACL) IF (MSVC OR ANDROID OR PNACL)
SET(EXTRA_COMPILE_FLAGS) SET(EXTRA_COMPILE_FLAGS)
IF (MSVC) 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}") 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) ENDIF (MSVC)
ELSE (MSVC OR ANDROID OR PNACL) ELSE (MSVC OR ANDROID OR PNACL)
SET(EXTRA_COMPILE_FLAGS "-msse2") SET(EXTRA_COMPILE_FLAGS "-msse2")
...@@ -142,7 +145,7 @@ IF (NOT CMAKE_CXX_FLAGS_RELEASE) ...@@ -142,7 +145,7 @@ IF (NOT CMAKE_CXX_FLAGS_RELEASE)
SET(CMAKE_CXX_FLAGS_RELEASE "-mfloat-abi=softfp -march=armv7-a -mfpu=neon -funsafe-math-optimizations -O3 -DNDEBUG" CACHE STRING SET(CMAKE_CXX_FLAGS_RELEASE "-mfloat-abi=softfp -march=armv7-a -mfpu=neon -funsafe-math-optimizations -O3 -DNDEBUG" CACHE STRING
"To use when CMAKE_BUILD_TYPE=Release" FORCE) "To use when CMAKE_BUILD_TYPE=Release" FORCE)
ELSE (ANDROID) ELSE (ANDROID)
SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING
"To use when CMAKE_BUILD_TYPE=Release" FORCE) "To use when CMAKE_BUILD_TYPE=Release" FORCE)
ENDIF (ANDROID) ENDIF (ANDROID)
ENDIF (NOT CMAKE_CXX_FLAGS_RELEASE) ENDIF (NOT CMAKE_CXX_FLAGS_RELEASE)
...@@ -205,11 +208,11 @@ SET(STATIC_TARGET ${OPENMM_LIBRARY_NAME}_static) ...@@ -205,11 +208,11 @@ SET(STATIC_TARGET ${OPENMM_LIBRARY_NAME}_static)
## If no one says otherwise, change the executable path to drop into the same binary ## If no one says otherwise, change the executable path to drop into the same binary
## location as the DLLs so that the test cases will use the just-build DLLs. ## location as the DLLs so that the test cases will use the just-build DLLs.
IF(NOT EXECUTABLE_OUTPUT_PATH) IF(NOT EXECUTABLE_OUTPUT_PATH)
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR} SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}
CACHE INTERNAL "Single output directory for building all executables.") CACHE INTERNAL "Single output directory for building all executables.")
ENDIF(NOT EXECUTABLE_OUTPUT_PATH) ENDIF(NOT EXECUTABLE_OUTPUT_PATH)
IF(NOT LIBRARY_OUTPUT_PATH) IF(NOT LIBRARY_OUTPUT_PATH)
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR} SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}
CACHE INTERNAL "Single output directory for building all libraries.") CACHE INTERNAL "Single output directory for building all libraries.")
ENDIF(NOT LIBRARY_OUTPUT_PATH) ENDIF(NOT LIBRARY_OUTPUT_PATH)
SET(${PROJECT_NAME}_EXECUTABLE_DIR ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}) SET(${PROJECT_NAME}_EXECUTABLE_DIR ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR})
...@@ -224,7 +227,7 @@ SET(API_INCLUDE_DIRS) # start empty ...@@ -224,7 +227,7 @@ SET(API_INCLUDE_DIRS) # start empty
FOREACH(subdir ${OPENMM_SOURCE_SUBDIRS}) FOREACH(subdir ${OPENMM_SOURCE_SUBDIRS})
# append # append
SET(API_INCLUDE_DIRS ${API_INCLUDE_DIRS} SET(API_INCLUDE_DIRS ${API_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}/${subdir}/include ${CMAKE_CURRENT_SOURCE_DIR}/${subdir}/include
${CMAKE_CURRENT_SOURCE_DIR}/${subdir}/include/openmm ${CMAKE_CURRENT_SOURCE_DIR}/${subdir}/include/openmm
${CMAKE_CURRENT_SOURCE_DIR}/${subdir}/include/openmm/internal) ${CMAKE_CURRENT_SOURCE_DIR}/${subdir}/include/openmm/internal)
ENDFOREACH(subdir) ENDFOREACH(subdir)
...@@ -364,7 +367,7 @@ IF(CUDA_FOUND) ...@@ -364,7 +367,7 @@ IF(CUDA_FOUND)
SET(OPENMM_BUILD_CUDA_LIB ON CACHE BOOL "Build OpenMMCuda library for Nvidia GPUs") SET(OPENMM_BUILD_CUDA_LIB ON CACHE BOOL "Build OpenMMCuda library for Nvidia GPUs")
# I wish I was not hardcoding /MD here # I wish I was not hardcoding /MD here
# Avoid strange windows link error with cuda free energy # Avoid strange windows link error with cuda free energy
# plugin by specifying /MD to CUDA_NVCC_FLAGS # plugin by specifying /MD to CUDA_NVCC_FLAGS
MARK_AS_ADVANCED(CLEAR CUDA_NVCC_FLAGS) MARK_AS_ADVANCED(CLEAR CUDA_NVCC_FLAGS)
IF(MSVC) IF(MSVC)
...@@ -380,7 +383,7 @@ IF(CUDA_FOUND) ...@@ -380,7 +383,7 @@ IF(CUDA_FOUND)
if(CUDA_NVCC_FLAGS) if(CUDA_NVCC_FLAGS)
set(new_flags "${CUDA_NVCC_FLAGS};${new_flags}") set(new_flags "${CUDA_NVCC_FLAGS};${new_flags}")
endif(CUDA_NVCC_FLAGS) endif(CUDA_NVCC_FLAGS)
SET(CUDA_NVCC_FLAGS "${new_flags}" SET(CUDA_NVCC_FLAGS "${new_flags}"
CACHE STRING "Semicolon delimit multiple arguments" FORCE) CACHE STRING "Semicolon delimit multiple arguments" FORCE)
ENDIF(NOT HAS_NVCC_FLAG) ENDIF(NOT HAS_NVCC_FLAG)
ENDIF(MSVC) ENDIF(MSVC)
......
...@@ -32,14 +32,16 @@ install: ...@@ -32,14 +32,16 @@ install:
# Run the build # Run the build
- jom install - jom install
- jom PythonInstall - jom PythonInstall
build: false build: false
test_script: test_script:
- ctest && exit 0 - 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 - 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: > - ps: >
If (Test-Path "FailedTests.log") { If (Test-Path "Testing\\Temporary\\LastTestsFailed.log") {
ctest -V -I FailedTests.log cat Testing\\Temporary\\LastTestsFailed.log
cat FailedTests.log
ctest -I FailedTests.log
} }
- cd python\tests - cd python\tests
- nosetests -vv --processes=-1 --process-timeout=200 - nosetests -vv --processes=-1 --process-timeout=200
......
...@@ -4,14 +4,21 @@ from simtk.openmm.app import * ...@@ -4,14 +4,21 @@ from simtk.openmm.app import *
from simtk.openmm import * from simtk.openmm import *
from simtk.unit import * from simtk.unit import *
import simtk.openmm.app.element as elem 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): def compareByElement(array1, array2, cmp):
for x, y in zip(array1, array2): for x, y in zip(array1, array2):
cmp(x, y) cmp(x, y)
class TestAmberInpcrdFile(unittest.TestCase): class TestAmberInpcrdFile(unittest.TestCase):
"""Test the Amber inpcrd file parser""" """Test the Amber inpcrd file parser"""
def test_CrdVelBox(self): def test_CrdVelBox(self):
""" Test parsing ASCII restarts with crds, vels, and box """ """ Test parsing ASCII restarts with crds, vels, and box """
cmp = self.assertAlmostEqual cmp = self.assertAlmostEqual
...@@ -24,24 +31,21 @@ class TestAmberInpcrdFile(unittest.TestCase): ...@@ -24,24 +31,21 @@ class TestAmberInpcrdFile(unittest.TestCase):
compareByElement(inpcrd.boxVectors[0].value_in_unit(angstroms), compareByElement(inpcrd.boxVectors[0].value_in_unit(angstroms),
[30.2642725, 0.0, 0.0], cmp) [30.2642725, 0.0, 0.0], cmp)
@unittest.skipIf(SCIPY_IMPORT_FAILED, "Scipy is not installed")
def test_NetCDF(self): def test_NetCDF(self):
""" Test NetCDF restart file parsing """ """ Test NetCDF restart file parsing """
cmp = self.assertAlmostEqual cmp = self.assertAlmostEqual
try:
from scipy.io import netcdf inpcrd = AmberInpcrdFile('systems/amber.ncrst')
except ImportError: self.assertEqual(len(inpcrd.positions), 2101)
print('Not testing NetCDF file parser... scipy cannot be found') compareByElement(inpcrd.positions[0].value_in_unit(angstroms),
else: [6.82122492718229, 6.6276250662042, -8.51668999892245],
inpcrd = AmberInpcrdFile('systems/amber.ncrst') cmp)
self.assertEqual(len(inpcrd.positions), 2101) compareByElement(inpcrd.velocities[-1].value_in_unit(angstroms/picosecond),
compareByElement(inpcrd.positions[0].value_in_unit(angstroms), [0.349702202733541*20.455, 0.391525333168534*20.455,
[6.82122492718229, 6.6276250662042, -8.51668999892245], 0.417941679767662*20.455], cmp)
cmp) self.assertAlmostEqual(inpcrd.boxVectors[0][0].value_in_unit(angstroms),
compareByElement(inpcrd.velocities[-1].value_in_unit(angstroms/picosecond), 30.2642725, places=6)
[0.349702202733541*20.455, 0.391525333168534*20.455,
0.417941679767662*20.455], cmp)
self.assertAlmostEqual(inpcrd.boxVectors[0][0].value_in_unit(angstroms),
30.2642725, places=6)
def test_CrdBox(self): def test_CrdBox(self):
""" Test parsing ASCII restarts with only crds and box """ """ Test parsing ASCII restarts with only crds and box """
......
import os import os
import unittest import unittest
import tempfile import tempfile
import numpy as np
from simtk.openmm import app from simtk.openmm import app
import simtk.openmm as mm import simtk.openmm as mm
from simtk import unit from simtk import unit
...@@ -24,17 +23,19 @@ class TestCheckpointReporter(unittest.TestCase): ...@@ -24,17 +23,19 @@ class TestCheckpointReporter(unittest.TestCase):
self.simulation.step(1) self.simulation.step(1)
# get the current positions # 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... # 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 # then reload the right positions from the checkpoint
file.close() file.close()
with open(file.name, 'rb') as f: with open(file.name, 'rb') as f:
self.simulation.context.loadCheckpoint(f.read()) self.simulation.context.loadCheckpoint(f.read())
os.unlink(file.name) os.unlink(file.name)
newPositions = self.simulation.context.getState(getPositions=True).getPositions(asNumpy=True)._value newPositions = self.simulation.context.getState(getPositions=True).getPositions()
np.testing.assert_array_equal(positions, newPositions) self.assertSequenceEqual(positions, newPositions)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
import unittest import unittest
import numpy as np
from simtk.openmm import app from simtk.openmm import app
import simtk.openmm as mm import simtk.openmm as mm
from simtk import unit 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): class TestNumpyCompatibility(unittest.TestCase):
def setUp(self): def setUp(self):
prmtop = app.AmberPrmtopFile('systems/water-box-216.prmtop') prmtop = app.AmberPrmtopFile('systems/water-box-216.prmtop')
system = prmtop.createSystem(nonbondedMethod=app.PME, system = prmtop.createSystem(nonbondedMethod=app.PME,
nonbondedCutoff=0.9*unit.nanometers, nonbondedCutoff=0.9*unit.nanometers,
constraints=app.HBonds, rigidWater=True, constraints=app.HBonds, rigidWater=True,
ewaldErrorTolerance=0.0005) ewaldErrorTolerance=0.0005)
integrator = mm.LangevinIntegrator(300*unit.kelvin, 1.0/unit.picoseconds, integrator = mm.LangevinIntegrator(300*unit.kelvin, 1.0/unit.picoseconds,
2.0*unit.femtoseconds) 2.0*unit.femtoseconds)
self.simulation = app.Simulation(prmtop.topology, system, integrator, self.simulation = app.Simulation(prmtop.topology, system, integrator,
mm.Platform.getPlatformByName('Reference')) mm.Platform.getPlatformByName('Reference'))
def test_setPositions(self): def test_setPositions(self):
n_particles = self.simulation.context.getSystem().getNumParticles() n_particles = self.simulation.context.getSystem().getNumParticles()
input = np.random.randn(n_particles, 3) input = np.random.randn(n_particles, 3)
self.simulation.context.setPositions(input) self.simulation.context.setPositions(input)
output = self.simulation.context.getState(getPositions=True).getPositions(asNumpy=True) output = self.simulation.context.getState(getPositions=True).getPositions(asNumpy=True)
np.testing.assert_array_almost_equal(input, output) np.testing.assert_array_almost_equal(input, output)
def test_setPositions_units(self): def test_setPositions_units(self):
n_particles = self.simulation.context.getSystem().getNumParticles() n_particles = self.simulation.context.getSystem().getNumParticles()
input = unit.Quantity(np.random.randn(n_particles, 3), unit.angstroms) input = unit.Quantity(np.random.randn(n_particles, 3), unit.angstroms)
self.simulation.context.setPositions(input) self.simulation.context.setPositions(input)
output = self.simulation.context.getState(getPositions=True).getPositions(asNumpy=True) output = self.simulation.context.getState(getPositions=True).getPositions(asNumpy=True)
np.testing.assert_array_almost_equal(input.value_in_unit(unit.nanometers), output.value_in_unit(unit.nanometers)) np.testing.assert_array_almost_equal(input.value_in_unit(unit.nanometers), output.value_in_unit(unit.nanometers))
def test_setVelocities(self): def test_setVelocities(self):
n_particles = self.simulation.context.getSystem().getNumParticles() n_particles = self.simulation.context.getSystem().getNumParticles()
input = np.random.randn(n_particles, 3) input = np.random.randn(n_particles, 3)
self.simulation.context.setVelocities(input) self.simulation.context.setVelocities(input)
output = self.simulation.context.getState(getVelocities=True).getVelocities(asNumpy=True) output = self.simulation.context.getState(getVelocities=True).getVelocities(asNumpy=True)
np.testing.assert_array_almost_equal(input, output) np.testing.assert_array_almost_equal(input, output)
def test_setVelocities_units(self): def test_setVelocities_units(self):
n_particles = self.simulation.context.getSystem().getNumParticles() n_particles = self.simulation.context.getSystem().getNumParticles()
input = unit.Quantity(np.random.randn(n_particles, 3), unit.angstroms / unit.femtoseconds) input = unit.Quantity(np.random.randn(n_particles, 3), unit.angstroms / unit.femtoseconds)
self.simulation.context.setVelocities(input) self.simulation.context.setVelocities(input)
output = self.simulation.context.getState(getVelocities=True).getVelocities(asNumpy=True) output = self.simulation.context.getState(getVelocities=True).getVelocities(asNumpy=True)
np.testing.assert_array_almost_equal(input.value_in_unit(unit.angstroms / unit.femtoseconds), np.testing.assert_array_almost_equal(input.value_in_unit(unit.angstroms / unit.femtoseconds),
output.value_in_unit(unit.angstroms / unit.femtoseconds)) output.value_in_unit(unit.angstroms / unit.femtoseconds))
def test_tabulatedFunction(self): def test_tabulatedFunction(self):
f = mm.CustomNonbondedForce('g(r)') f = mm.CustomNonbondedForce('g(r)')
r = np.linspace(0,10) r = np.linspace(0,10)
g_of_r = np.sin(r) g_of_r = np.sin(r)
indx = f.addFunction('g', g_of_r, np.min(r), np.max(r)) indx = f.addFunction('g', g_of_r, np.min(r), np.max(r))
name, g_of_r_out, min_r_out, max_r_out = f.getFunctionParameters(indx) name, g_of_r_out, min_r_out, max_r_out = f.getFunctionParameters(indx)
np.testing.assert_array_almost_equal(g_of_r, np.asarray(g_of_r_out)) np.testing.assert_array_almost_equal(g_of_r, np.asarray(g_of_r_out))
assert min_r_out == np.min(r) assert min_r_out == np.min(r)
assert max_r_out == np.max(r) assert max_r_out == np.max(r)
def test_CMAP(self): def test_CMAP(self):
f = mm.CMAPTorsionForce() f = mm.CMAPTorsionForce()
energy = np.random.randn(10*10) energy = np.random.randn(10*10)
...@@ -76,10 +81,12 @@ class TestNumpyCompatibility(unittest.TestCase): ...@@ -76,10 +81,12 @@ class TestNumpyCompatibility(unittest.TestCase):
size, energy_out = f.getMapParameters(0) size, energy_out = f.getMapParameters(0)
energy_out = energy_out.value_in_unit_system(unit.md_unit_system) energy_out = energy_out.value_in_unit_system(unit.md_unit_system)
self.assertEqual(size, 10) self.assertEqual(size, 10)
np.testing.assert_array_almost_equal(energy, np.asarray(energy_out)) np.testing.assert_array_almost_equal(energy, np.asarray(energy_out))
@unittest.skipIf(NUMPY_IMPORT_FAILED, 'Numpy is not installed')
class TestNumpyUnits(unittest.TestCase): class TestNumpyUnits(unittest.TestCase):
def setUp(self): 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