if mapping is none, create an identity map that is size indactive.nonzero for regularization

This commit is contained in:
Lindsey Heagy
2016-05-03 15:04:36 -07:00
parent 23d2783bc1
commit 00bbe0f35e
2 changed files with 4 additions and 3 deletions
+3
View File
@@ -311,6 +311,9 @@ class BaseRegularization(object):
tmp = indActive
indActive = np.zeros(mesh.nC, dtype=bool)
indActive[tmp] = True
if indActive is not None and mapping is None:
mapping = Maps.IdentityMap(nP=indActive.nonzero()[0].size)
self.regmesh = RegularizationMesh(mesh,indActive)
self.mapping = mapping or self.mapPair(mesh)
self.mapping._assertMatchesPair(self.mapPair)
+1 -3
View File
@@ -65,10 +65,8 @@ class RegularizationTests(unittest.TestCase):
elif mesh.dim == 3:
indActive = Utils.mkvc(mesh.gridCC[:,-1] <= 2*np.sin(2*np.pi*mesh.gridCC[:,0])+0.5 * 2*np.sin(2*np.pi*mesh.gridCC[:,1])+0.5)
mapping = Maps.IdentityMap(nP=indActive.nonzero()[0].size)
for indAct in [indActive, indActive.nonzero()[0]]: # test both bool and integers
reg = r(mesh, mapping=mapping, indActive=indAct)
reg = r(mesh, indActive=indAct)
m = np.random.rand(mesh.nC)[indAct]
reg.mref = np.ones_like(m)*np.mean(m)