def test_regularization(self):
     for R in dir(Regularization):
         r = getattr(Regularization, R)
         if not inspect.isclass(r): continue
         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)
         self.assertTrue(passed)
 def doTestFace(self, h, rep, fast, meshType, invProp=False, invMat=False):
     if meshType == 'Curv':
         hRect = Utils.exampleLrmGrid(h,'rotate')
         mesh = Mesh.CurvilinearMesh(hRect)
     elif meshType == 'Tree':
         mesh = Mesh.TreeMesh(h)
     elif meshType == 'Tensor':
         mesh = Mesh.TensorMesh(h)
     v = np.random.rand(mesh.nF)
     sig = np.random.rand(1) if rep is 0 else np.random.rand(mesh.nC*rep)
     def fun(sig):
         M  = mesh.getFaceInnerProduct(sig, invProp=invProp, invMat=invMat)
         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)