light pep8 formatting in tests

This commit is contained in:
Lindsey Heagy
2016-07-16 16:26:36 -07:00
parent 6826df8989
commit 62b3a3a218
3 changed files with 18 additions and 11 deletions
+14 -7
View File
@@ -8,6 +8,7 @@ TOL = 1e-20
testReg = True
testRegMesh = True
class RegularizationTests(unittest.TestCase):
def setUp(self):
@@ -16,41 +17,47 @@ class RegularizationTests(unittest.TestCase):
mesh1 = Mesh.TensorMesh([hx])
mesh2 = Mesh.TensorMesh([hx, hy])
mesh3 = Mesh.TensorMesh([hx, hy, hz])
self.meshlist = [mesh1,mesh2, mesh3]
self.meshlist = [mesh1, mesh2, mesh3]
if testReg:
def test_regularization(self):
for R in dir(Regularization):
r = getattr(Regularization, R)
if not inspect.isclass(r): continue
if not inspect.isclass(r):
continue
if not issubclass(r, Regularization.BaseRegularization):
continue
for i, mesh in enumerate(self.meshlist):
print 'Testing %iD'%mesh.dim
print 'Testing %iD' % mesh.dim
mapping = r.mapPair(mesh)
reg = r(mesh, mapping=mapping)
m = np.random.rand(mapping.nP)
reg.mref = np.ones_like(m)*np.mean(m)
print 'Check: phi_m (mref) = %f' %reg.eval(reg.mref)
print 'Check: phi_m (mref) = %f' % reg.eval(reg.mref)
passed = reg.eval(reg.mref) < TOL
self.assertTrue(passed)
print 'Check:', R
passed = Tests.checkDerivative(lambda m : [reg.eval(m), reg.evalDeriv(m)], m, plotIt=False)
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)
passed = Tests.checkDerivative(lambda m: [reg.evalDeriv(m),
reg.eval2Deriv(m)], m,
plotIt=False)
self.assertTrue(passed)
def test_regularization_ActiveCells(self):
for R in dir(Regularization):
r = getattr(Regularization, R)
if not inspect.isclass(r): continue
if not inspect.isclass(r):
continue
if not issubclass(r, Regularization.BaseRegularization):
continue