Separate tests into folders.

Build in a matrix?
This commit is contained in:
Rowan Cockett
2015-10-30 13:39:01 -07:00
parent 0885b72577
commit b8fe0cfdbf
28 changed files with 81 additions and 41 deletions
+8 -5
View File
@@ -4,6 +4,12 @@ python:
sudo: false sudo: false
env:
- TEST_DIR=tests/utils
- TEST_DIR=tests/mesh
- TEST_DIR=tests/base
- TEST_DIR=tests/examples
# Setup anaconda # Setup anaconda
before_install: before_install:
- if [ ${TRAVIS_PYTHON_VERSION:0:1} == "2" ]; then wget http://repo.continuum.io/miniconda/Miniconda-3.8.3-Linux-x86_64.sh -O miniconda.sh; else wget http://repo.continuum.io/miniconda/Miniconda3-3.8.3-Linux-x86_64.sh -O miniconda.sh; fi - if [ ${TRAVIS_PYTHON_VERSION:0:1} == "2" ]; then wget http://repo.continuum.io/miniconda/Miniconda-3.8.3-Linux-x86_64.sh -O miniconda.sh; else wget http://repo.continuum.io/miniconda/Miniconda3-3.8.3-Linux-x86_64.sh -O miniconda.sh; fi
@@ -11,20 +17,17 @@ before_install:
- ./miniconda.sh -b - ./miniconda.sh -b
- export PATH=/home/travis/anaconda/bin:/home/travis/miniconda/bin:$PATH - export PATH=/home/travis/anaconda/bin:/home/travis/miniconda/bin:$PATH
- conda update --yes conda - conda update --yes conda
# The next couple lines fix a crash with multiprocessing on Travis and are not specific to using Miniconda
# - sudo rm -rf /dev/shm
# - sudo ln -s /run/shm /dev/shm
# Install packages # Install packages
install: install:
- conda install --yes pip python=$TRAVIS_PYTHON_VERSION numpy scipy matplotlib cython - conda install --yes pip python=$TRAVIS_PYTHON_VERSION numpy scipy matplotlib cython ipython
- pip install nose-cov python-coveralls - pip install nose-cov python-coveralls
# - pip install -r requirements.txt # - pip install -r requirements.txt
- python setup.py install - python setup.py install
# Run test # Run test
script: script:
- nosetests --with-cov --cov SimPEG --cov-config .coveragerc -v -s - nosetests $TEST_DIR --with-cov --cov SimPEG --cov-config .coveragerc -v -s
# Calculate coverage # Calculate coverage
after_success: after_success:
@@ -1,6 +1,3 @@
from TestUtils import checkDerivative, Rosenbrock, OrderTest, getQuadratic
if __name__ == '__main__': if __name__ == '__main__':
import os import os
import glob import glob
+11
View File
@@ -0,0 +1,11 @@
if __name__ == '__main__':
import os
import glob
import unittest
test_file_strings = glob.glob('test_*.py')
module_strings = [str[0:len(str)-3] for str in test_file_strings]
suites = [unittest.defaultTestLoader.loadTestsFromName(str) for str
in module_strings]
testSuite = unittest.TestSuite(suites)
unittest.TextTestRunner(verbosity=2).run(testSuite)
@@ -1,7 +1,6 @@
import numpy as np import numpy as np
import unittest import unittest
from SimPEG import * from SimPEG import *
from TestUtils import checkDerivative
from scipy.sparse.linalg import dsolve from scipy.sparse.linalg import dsolve
TOL = 1e-14 TOL = 1e-14
@@ -1,7 +1,6 @@
import numpy as np import numpy as np
import unittest import unittest
from SimPEG import * from SimPEG import *
from TestUtils import checkDerivative
from scipy.sparse.linalg import dsolve from scipy.sparse.linalg import dsolve
import inspect import inspect
@@ -18,12 +17,16 @@ class RegularizationTests(unittest.TestCase):
if not issubclass(r, Regularization.BaseRegularization): if not issubclass(r, Regularization.BaseRegularization):
continue continue
# if 'Regularization' not in R: continue # if 'Regularization' not in R: continue
print 'Check:', R
mapping = r.mapPair(self.mesh2) mapping = r.mapPair(self.mesh2)
reg = r(self.mesh2, mapping=mapping) reg = r(self.mesh2, mapping=mapping)
m = np.random.rand(mapping.nP) m = np.random.rand(mapping.nP)
reg.mref = m[:]*np.mean(m) reg.mref = m[:]*np.mean(m)
passed = checkDerivative(lambda m : [reg.eval(m), reg.evalDeriv(m)], m, plotIt=False)
print 'Check:', R
passed = Tests.checkDerivative(lambda m : [reg.eval(m), reg.evalDeriv(m)], m, plotIt=False)
self.assertTrue(passed)
print 'Check 2 Deriv:', R
passed = Tests.checkDerivative(lambda m : [reg.evalDeriv(m), reg.eval2Deriv(m)], m, plotIt=False)
self.assertTrue(passed) self.assertTrue(passed)
+11
View File
@@ -0,0 +1,11 @@
if __name__ == '__main__':
import os
import glob
import unittest
test_file_strings = glob.glob('test_*.py')
module_strings = [str[0:len(str)-3] for str in test_file_strings]
suites = [unittest.defaultTestLoader.loadTestsFromName(str) for str
in module_strings]
testSuite = unittest.TestSuite(suites)
unittest.TextTestRunner(verbosity=2).run(testSuite)
+11
View File
@@ -0,0 +1,11 @@
if __name__ == '__main__':
import os
import glob
import unittest
test_file_strings = glob.glob('test_*.py')
module_strings = [str[0:len(str)-3] for str in test_file_strings]
suites = [unittest.defaultTestLoader.loadTestsFromName(str) for str
in module_strings]
testSuite = unittest.TestSuite(suites)
unittest.TextTestRunner(verbosity=2).run(testSuite)
@@ -1,13 +1,12 @@
import numpy as np import numpy as np
import scipy.sparse as sp import scipy.sparse as sp
import unittest import unittest
from TestUtils import OrderTest
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
from SimPEG import * from SimPEG import *
MESHTYPES = ['uniformTensorMesh'] MESHTYPES = ['uniformTensorMesh']
class Test1D_InhomogeneousDirichlet(OrderTest): class Test1D_InhomogeneousDirichlet(Tests.OrderTest):
name = "1D - Dirichlet" name = "1D - Dirichlet"
meshTypes = MESHTYPES meshTypes = MESHTYPES
meshDimension = 1 meshDimension = 1
@@ -88,7 +87,7 @@ class Test1D_InhomogeneousDirichlet(OrderTest):
self.orderTest() self.orderTest()
class Test2D_InhomogeneousDirichlet(OrderTest): class Test2D_InhomogeneousDirichlet(Tests.OrderTest):
name = "2D - Dirichlet" name = "2D - Dirichlet"
meshTypes = MESHTYPES meshTypes = MESHTYPES
meshDimension = 2 meshDimension = 2
@@ -169,7 +168,7 @@ class Test2D_InhomogeneousDirichlet(OrderTest):
self.myTest = 'xcJ' self.myTest = 'xcJ'
self.orderTest() self.orderTest()
class Test1D_InhomogeneousNeumann(OrderTest): class Test1D_InhomogeneousNeumann(Tests.OrderTest):
name = "1D - Neumann" name = "1D - Neumann"
meshTypes = MESHTYPES meshTypes = MESHTYPES
meshDimension = 1 meshDimension = 1
@@ -246,7 +245,7 @@ class Test1D_InhomogeneousNeumann(OrderTest):
self.myTest = 'xcJ' self.myTest = 'xcJ'
self.orderTest() self.orderTest()
class Test2D_InhomogeneousNeumann(OrderTest): class Test2D_InhomogeneousNeumann(Tests.OrderTest):
name = "2D - Neumann" name = "2D - Neumann"
meshTypes = MESHTYPES meshTypes = MESHTYPES
meshDimension = 2 meshDimension = 2
@@ -333,7 +332,7 @@ class Test2D_InhomogeneousNeumann(OrderTest):
self.myTest = 'xcJ' self.myTest = 'xcJ'
self.orderTest() self.orderTest()
class Test1D_InhomogeneousMixed(OrderTest): class Test1D_InhomogeneousMixed(Tests.OrderTest):
name = "1D - Mixed" name = "1D - Mixed"
meshTypes = MESHTYPES meshTypes = MESHTYPES
meshDimension = 1 meshDimension = 1
@@ -410,7 +409,7 @@ class Test1D_InhomogeneousMixed(OrderTest):
self.myTest = 'xcJ' self.myTest = 'xcJ'
self.orderTest() self.orderTest()
class Test2D_InhomogeneousMixed(OrderTest): class Test2D_InhomogeneousMixed(Tests.OrderTest):
name = "2D - Mixed" name = "2D - Mixed"
meshTypes = MESHTYPES meshTypes = MESHTYPES
meshDimension = 2 meshDimension = 2
@@ -1,7 +1,6 @@
import unittest import unittest
import sys import sys
from SimPEG import * from SimPEG import *
from TestUtils import OrderTest
class TestCyl2DMesh(unittest.TestCase): class TestCyl2DMesh(unittest.TestCase):
@@ -217,7 +216,7 @@ cyl_row3 = lambda g, xfun, yfun, zfun: np.c_[call3(xfun, g), call3(yfun, g), cal
cylF2 = lambda M, fx, fy: np.vstack((cyl_row2(M.gridFx, fx, fy), cyl_row2(M.gridFz, fx, fy))) cylF2 = lambda M, fx, fy: np.vstack((cyl_row2(M.gridFx, fx, fy), cyl_row2(M.gridFz, fx, fy)))
class TestFaceDiv2D(OrderTest): class TestFaceDiv2D(Tests.OrderTest):
name = "FaceDiv" name = "FaceDiv"
meshTypes = MESHTYPES meshTypes = MESHTYPES
meshDimension = 2 meshDimension = 2
@@ -242,7 +241,7 @@ class TestFaceDiv2D(OrderTest):
def test_order(self): def test_order(self):
self.orderTest() self.orderTest()
class TestEdgeCurl2D(OrderTest): class TestEdgeCurl2D(Tests.OrderTest):
name = "EdgeCurl" name = "EdgeCurl"
meshTypes = MESHTYPES meshTypes = MESHTYPES
meshDimension = 2 meshDimension = 2
@@ -281,7 +280,7 @@ class TestEdgeCurl2D(OrderTest):
self.orderTest() self.orderTest()
# class TestInnerProducts2D(OrderTest): # class TestInnerProducts2D(Tests.OrderTest):
# """Integrate an function over a unit cube domain using edgeInnerProducts and faceInnerProducts.""" # """Integrate an function over a unit cube domain using edgeInnerProducts and faceInnerProducts."""
# meshTypes = MESHTYPES # meshTypes = MESHTYPES
@@ -1,10 +1,9 @@
import numpy as np import numpy as np
import unittest import unittest
from TestUtils import OrderTest from SimPEG import Utils, Tests
from SimPEG import Utils
class TestInnerProducts(OrderTest): class TestInnerProducts(Tests.OrderTest):
"""Integrate an function over a unit cube domain using edgeInnerProducts and faceInnerProducts.""" """Integrate an function over a unit cube domain using edgeInnerProducts and faceInnerProducts."""
meshTypes = ['uniformTensorMesh', 'uniformCurv', 'rotateCurv'] meshTypes = ['uniformTensorMesh', 'uniformCurv', 'rotateCurv']
@@ -151,7 +150,7 @@ class TestInnerProducts(OrderTest):
self.orderTest() self.orderTest()
class TestInnerProducts2D(OrderTest): class TestInnerProducts2D(Tests.OrderTest):
"""Integrate an function over a unit cube domain using edgeInnerProducts and faceInnerProducts.""" """Integrate an function over a unit cube domain using edgeInnerProducts and faceInnerProducts."""
meshTypes = ['uniformTensorMesh', 'uniformCurv', 'rotateCurv'] meshTypes = ['uniformTensorMesh', 'uniformCurv', 'rotateCurv']
@@ -293,7 +292,7 @@ class TestInnerProducts2D(OrderTest):
class TestInnerProducts1D(OrderTest): class TestInnerProducts1D(Tests.OrderTest):
"""Integrate an function over a unit cube domain using edgeInnerProducts and faceInnerProducts.""" """Integrate an function over a unit cube domain using edgeInnerProducts and faceInnerProducts."""
meshTypes = ['uniformTensorMesh'] meshTypes = ['uniformTensorMesh']
@@ -1,7 +1,6 @@
import numpy as np import numpy as np
import unittest import unittest
from SimPEG import * from SimPEG import *
from TestUtils import checkDerivative
class TestInnerProductsDerivs(unittest.TestCase): class TestInnerProductsDerivs(unittest.TestCase):
@@ -21,7 +20,7 @@ class TestInnerProductsDerivs(unittest.TestCase):
Md = mesh.getFaceInnerProductDeriv(sig, invProp=invProp, invMat=invMat, doFast=fast) Md = mesh.getFaceInnerProductDeriv(sig, invProp=invProp, invMat=invMat, doFast=fast)
return M*v, Md(v) return M*v, Md(v)
print meshType, 'Face', h, rep, fast, ('harmonic' if invProp and invMat else 'standard') print meshType, 'Face', h, rep, fast, ('harmonic' if invProp and invMat else 'standard')
return checkDerivative(fun, sig, num=5, plotIt=False) return Tests.checkDerivative(fun, sig, num=5, plotIt=False)
def doTestEdge(self, h, rep, fast, meshType, invProp=False, invMat=False): def doTestEdge(self, h, rep, fast, meshType, invProp=False, invMat=False):
if meshType == 'Curv': if meshType == 'Curv':
@@ -38,7 +37,7 @@ class TestInnerProductsDerivs(unittest.TestCase):
Md = mesh.getEdgeInnerProductDeriv(sig, invProp=invProp, invMat=invMat, doFast=fast) Md = mesh.getEdgeInnerProductDeriv(sig, invProp=invProp, invMat=invMat, doFast=fast)
return M*v, Md(v) return M*v, Md(v)
print meshType, 'Edge', h, rep, fast, ('harmonic' if invProp and invMat else 'standard') print meshType, 'Edge', h, rep, fast, ('harmonic' if invProp and invMat else 'standard')
return checkDerivative(fun, sig, num=5, plotIt=False) return Tests.checkDerivative(fun, sig, num=5, plotIt=False)
def test_FaceIP_1D_float(self): def test_FaceIP_1D_float(self):
self.assertTrue(self.doTestFace([10],0, False, 'Tensor')) self.assertTrue(self.doTestFace([10],0, False, 'Tensor'))
@@ -1,8 +1,7 @@
import numpy as np import numpy as np
import unittest import unittest
from TestUtils import OrderTest
from SimPEG.Utils import mkvc from SimPEG.Utils import mkvc
from SimPEG import Mesh from SimPEG import Mesh, Tests
import unittest import unittest
@@ -23,7 +22,7 @@ cartE3 = lambda M, ex, ey, ez: np.vstack((cart_row3(M.gridEx, ex, ey, ez), cart_
TOL = 1e-7 TOL = 1e-7
class TestInterpolation1D(OrderTest): class TestInterpolation1D(Tests.OrderTest):
LOCS = np.random.rand(50)*0.6+0.2 LOCS = np.random.rand(50)*0.6+0.2
name = "Interpolation 1D" name = "Interpolation 1D"
meshTypes = MESHTYPES meshTypes = MESHTYPES
@@ -69,7 +68,7 @@ class TestOutliersInterp1D(unittest.TestCase):
Q = M.getInterpolationMat(np.array([[-1],[0.126],[0.127]]),'CC',zerosOutside=True) Q = M.getInterpolationMat(np.array([[-1],[0.126],[0.127]]),'CC',zerosOutside=True)
self.assertTrue(np.linalg.norm(Q*x - np.r_[0,1.004,1.008]) < TOL) self.assertTrue(np.linalg.norm(Q*x - np.r_[0,1.004,1.008]) < TOL)
class TestInterpolation2d(OrderTest): class TestInterpolation2d(Tests.OrderTest):
name = "Interpolation 2D" name = "Interpolation 2D"
LOCS = np.random.rand(50,2)*0.6+0.2 LOCS = np.random.rand(50,2)*0.6+0.2
meshTypes = MESHTYPES meshTypes = MESHTYPES
@@ -152,7 +151,7 @@ class TestInterpolation2dCyl_Simple(unittest.TestCase):
self.assertRaises(Exception,lambda:M.getInterpolationMat(locs, 'Ez')) self.assertRaises(Exception,lambda:M.getInterpolationMat(locs, 'Ez'))
class TestInterpolation2dCyl(OrderTest): class TestInterpolation2dCyl(Tests.OrderTest):
name = "Interpolation 2D" name = "Interpolation 2D"
LOCS = np.c_[np.random.rand(4)*0.6+0.2, np.zeros(4), np.random.rand(4)*0.6+0.2] LOCS = np.c_[np.random.rand(4)*0.6+0.2, np.zeros(4), np.random.rand(4)*0.6+0.2]
meshTypes = ['uniformCylMesh'] # MESHTYPES + meshTypes = ['uniformCylMesh'] # MESHTYPES +
@@ -220,7 +219,7 @@ class TestInterpolation2dCyl(OrderTest):
self.name = 'Interpolation 2D CYLMESH: Ey' self.name = 'Interpolation 2D CYLMESH: Ey'
self.orderTest() self.orderTest()
class TestInterpolation3D(OrderTest): class TestInterpolation3D(Tests.OrderTest):
name = "Interpolation" name = "Interpolation"
LOCS = np.random.rand(50,3)*0.6+0.2 LOCS = np.random.rand(50,3)*0.6+0.2
meshTypes = MESHTYPES meshTypes = MESHTYPES
@@ -1,6 +1,6 @@
import numpy as np import numpy as np
import unittest import unittest
from TestUtils import OrderTest from SimPEG.Tests import OrderTest
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
#TODO: 'randomTensorMesh' #TODO: 'randomTensorMesh'
@@ -1,8 +1,7 @@
import numpy as np import numpy as np
import unittest import unittest
from SimPEG.Mesh import TensorMesh from SimPEG.Mesh import TensorMesh
from TestUtils import OrderTest from SimPEG import Solver, Tests
from SimPEG import Solver
TOL = 1e-10 TOL = 1e-10
@@ -91,7 +90,7 @@ class BasicTensorMeshTests(unittest.TestCase):
M = TensorMesh([[(10.,2)]]) M = TensorMesh([[(10.,2)]])
self.assertLess(np.abs(M.hx - np.r_[10.,10.]).sum(), TOL) self.assertLess(np.abs(M.hx - np.r_[10.,10.]).sum(), TOL)
class TestPoissonEqn(OrderTest): class TestPoissonEqn(Tests.OrderTest):
name = "Poisson Equation" name = "Poisson Equation"
meshSizes = [10, 16, 20] meshSizes = [10, 16, 20]
+11
View File
@@ -0,0 +1,11 @@
if __name__ == '__main__':
import os
import glob
import unittest
test_file_strings = glob.glob('test_*.py')
module_strings = [str[0:len(str)-3] for str in test_file_strings]
suites = [unittest.defaultTestLoader.loadTestsFromName(str) for str
in module_strings]
testSuite = unittest.TestSuite(suites)
unittest.TextTestRunner(verbosity=2).run(testSuite)