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
env:
- TEST_DIR=tests/utils
- TEST_DIR=tests/mesh
- TEST_DIR=tests/base
- TEST_DIR=tests/examples
# Setup anaconda
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
@@ -11,20 +17,17 @@ before_install:
- ./miniconda.sh -b
- export PATH=/home/travis/anaconda/bin:/home/travis/miniconda/bin:$PATH
- 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:
- 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 -r requirements.txt
- python setup.py install
# Run test
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
after_success:
@@ -1,6 +1,3 @@
from TestUtils import checkDerivative, Rosenbrock, OrderTest, getQuadratic
if __name__ == '__main__':
import os
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 unittest
from SimPEG import *
from TestUtils import checkDerivative
from scipy.sparse.linalg import dsolve
TOL = 1e-14
@@ -1,7 +1,6 @@
import numpy as np
import unittest
from SimPEG import *
from TestUtils import checkDerivative
from scipy.sparse.linalg import dsolve
import inspect
@@ -18,12 +17,16 @@ class RegularizationTests(unittest.TestCase):
if not issubclass(r, Regularization.BaseRegularization):
continue
# if 'Regularization' not in R: continue
print 'Check:', R
mapping = r.mapPair(self.mesh2)
reg = r(self.mesh2, mapping=mapping)
m = np.random.rand(mapping.nP)
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)
+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 scipy.sparse as sp
import unittest
from TestUtils import OrderTest
import matplotlib.pyplot as plt
from SimPEG import *
MESHTYPES = ['uniformTensorMesh']
class Test1D_InhomogeneousDirichlet(OrderTest):
class Test1D_InhomogeneousDirichlet(Tests.OrderTest):
name = "1D - Dirichlet"
meshTypes = MESHTYPES
meshDimension = 1
@@ -88,7 +87,7 @@ class Test1D_InhomogeneousDirichlet(OrderTest):
self.orderTest()
class Test2D_InhomogeneousDirichlet(OrderTest):
class Test2D_InhomogeneousDirichlet(Tests.OrderTest):
name = "2D - Dirichlet"
meshTypes = MESHTYPES
meshDimension = 2
@@ -169,7 +168,7 @@ class Test2D_InhomogeneousDirichlet(OrderTest):
self.myTest = 'xcJ'
self.orderTest()
class Test1D_InhomogeneousNeumann(OrderTest):
class Test1D_InhomogeneousNeumann(Tests.OrderTest):
name = "1D - Neumann"
meshTypes = MESHTYPES
meshDimension = 1
@@ -246,7 +245,7 @@ class Test1D_InhomogeneousNeumann(OrderTest):
self.myTest = 'xcJ'
self.orderTest()
class Test2D_InhomogeneousNeumann(OrderTest):
class Test2D_InhomogeneousNeumann(Tests.OrderTest):
name = "2D - Neumann"
meshTypes = MESHTYPES
meshDimension = 2
@@ -333,7 +332,7 @@ class Test2D_InhomogeneousNeumann(OrderTest):
self.myTest = 'xcJ'
self.orderTest()
class Test1D_InhomogeneousMixed(OrderTest):
class Test1D_InhomogeneousMixed(Tests.OrderTest):
name = "1D - Mixed"
meshTypes = MESHTYPES
meshDimension = 1
@@ -410,7 +409,7 @@ class Test1D_InhomogeneousMixed(OrderTest):
self.myTest = 'xcJ'
self.orderTest()
class Test2D_InhomogeneousMixed(OrderTest):
class Test2D_InhomogeneousMixed(Tests.OrderTest):
name = "2D - Mixed"
meshTypes = MESHTYPES
meshDimension = 2
@@ -1,7 +1,6 @@
import unittest
import sys
from SimPEG import *
from TestUtils import OrderTest
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)))
class TestFaceDiv2D(OrderTest):
class TestFaceDiv2D(Tests.OrderTest):
name = "FaceDiv"
meshTypes = MESHTYPES
meshDimension = 2
@@ -242,7 +241,7 @@ class TestFaceDiv2D(OrderTest):
def test_order(self):
self.orderTest()
class TestEdgeCurl2D(OrderTest):
class TestEdgeCurl2D(Tests.OrderTest):
name = "EdgeCurl"
meshTypes = MESHTYPES
meshDimension = 2
@@ -281,7 +280,7 @@ class TestEdgeCurl2D(OrderTest):
self.orderTest()
# class TestInnerProducts2D(OrderTest):
# class TestInnerProducts2D(Tests.OrderTest):
# """Integrate an function over a unit cube domain using edgeInnerProducts and faceInnerProducts."""
# meshTypes = MESHTYPES
@@ -1,10 +1,9 @@
import numpy as np
import unittest
from TestUtils import OrderTest
from SimPEG import Utils
from SimPEG import Utils, Tests
class TestInnerProducts(OrderTest):
class TestInnerProducts(Tests.OrderTest):
"""Integrate an function over a unit cube domain using edgeInnerProducts and faceInnerProducts."""
meshTypes = ['uniformTensorMesh', 'uniformCurv', 'rotateCurv']
@@ -151,7 +150,7 @@ class TestInnerProducts(OrderTest):
self.orderTest()
class TestInnerProducts2D(OrderTest):
class TestInnerProducts2D(Tests.OrderTest):
"""Integrate an function over a unit cube domain using edgeInnerProducts and faceInnerProducts."""
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."""
meshTypes = ['uniformTensorMesh']
@@ -1,7 +1,6 @@
import numpy as np
import unittest
from SimPEG import *
from TestUtils import checkDerivative
class TestInnerProductsDerivs(unittest.TestCase):
@@ -21,7 +20,7 @@ class TestInnerProductsDerivs(unittest.TestCase):
Md = mesh.getFaceInnerProductDeriv(sig, invProp=invProp, invMat=invMat, doFast=fast)
return M*v, Md(v)
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):
if meshType == 'Curv':
@@ -38,7 +37,7 @@ class TestInnerProductsDerivs(unittest.TestCase):
Md = mesh.getEdgeInnerProductDeriv(sig, invProp=invProp, invMat=invMat, doFast=fast)
return M*v, Md(v)
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):
self.assertTrue(self.doTestFace([10],0, False, 'Tensor'))
@@ -1,8 +1,7 @@
import numpy as np
import unittest
from TestUtils import OrderTest
from SimPEG.Utils import mkvc
from SimPEG import Mesh
from SimPEG import Mesh, Tests
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
class TestInterpolation1D(OrderTest):
class TestInterpolation1D(Tests.OrderTest):
LOCS = np.random.rand(50)*0.6+0.2
name = "Interpolation 1D"
meshTypes = MESHTYPES
@@ -69,7 +68,7 @@ class TestOutliersInterp1D(unittest.TestCase):
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)
class TestInterpolation2d(OrderTest):
class TestInterpolation2d(Tests.OrderTest):
name = "Interpolation 2D"
LOCS = np.random.rand(50,2)*0.6+0.2
meshTypes = MESHTYPES
@@ -152,7 +151,7 @@ class TestInterpolation2dCyl_Simple(unittest.TestCase):
self.assertRaises(Exception,lambda:M.getInterpolationMat(locs, 'Ez'))
class TestInterpolation2dCyl(OrderTest):
class TestInterpolation2dCyl(Tests.OrderTest):
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]
meshTypes = ['uniformCylMesh'] # MESHTYPES +
@@ -220,7 +219,7 @@ class TestInterpolation2dCyl(OrderTest):
self.name = 'Interpolation 2D CYLMESH: Ey'
self.orderTest()
class TestInterpolation3D(OrderTest):
class TestInterpolation3D(Tests.OrderTest):
name = "Interpolation"
LOCS = np.random.rand(50,3)*0.6+0.2
meshTypes = MESHTYPES
@@ -1,6 +1,6 @@
import numpy as np
import unittest
from TestUtils import OrderTest
from SimPEG.Tests import OrderTest
import matplotlib.pyplot as plt
#TODO: 'randomTensorMesh'
@@ -1,8 +1,7 @@
import numpy as np
import unittest
from SimPEG.Mesh import TensorMesh
from TestUtils import OrderTest
from SimPEG import Solver
from SimPEG import Solver, Tests
TOL = 1e-10
@@ -91,7 +90,7 @@ class BasicTensorMeshTests(unittest.TestCase):
M = TensorMesh([[(10.,2)]])
self.assertLess(np.abs(M.hx - np.r_[10.,10.]).sum(), TOL)
class TestPoissonEqn(OrderTest):
class TestPoissonEqn(Tests.OrderTest):
name = "Poisson Equation"
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)