From c40d11ef53db694d1b49abab92727cdc60f59349 Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Sun, 26 Jun 2016 15:24:33 -0700 Subject: [PATCH] - better model for testing Parametric casing map - allow vector containing values in the inactive set to be passed (not just nC in length) --- SimPEG/Maps.py | 12 ++++++++++-- tests/base/test_maps.py | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/SimPEG/Maps.py b/SimPEG/Maps.py index 027b65c8..caa15693 100644 --- a/SimPEG/Maps.py +++ b/SimPEG/Maps.py @@ -543,11 +543,19 @@ class InjectActiveCells(IdentityMap): self.indInactive = np.logical_not(indActive) if Utils.isScalar(valInactive): self.valInactive = np.ones(self.nC)*float(valInactive) + self.valInactive[self.indActive] = 0. else: - self.valInactive = valInactive.copy() - self.valInactive[self.indActive] = 0 + if len(valInactive) == sum(self.indInactive): + self.valInactive = np.zeros(nC) + self.valInactive[self.indInactive] = valInactive.copy() + else: + assert len(self.valInactive) == self.nC, 'valInactive must be the size of nC or nInactive' + self.valInactive = valInactive.copy() + if any(self.valInactive[self.indActive] != 0.): + warnings.warn('the inactive has non-zero values in the active set.') inds = np.nonzero(self.indActive)[0] + # inds[self.indActive] self.P = sp.csr_matrix((np.ones(inds.size),(inds, range(inds.size))), shape=(self.nC, self.nP)) @property diff --git a/tests/base/test_maps.py b/tests/base/test_maps.py index e9fe6d3f..c6e06c51 100644 --- a/tests/base/test_maps.py +++ b/tests/base/test_maps.py @@ -39,7 +39,7 @@ class MapTests(unittest.TestCase): def test_ParametricCasingAndLayer(self): mapping = Maps.ParametrizedCasingAndLayer(self.meshCyl) - m = np.r_[-2., 1., 6., 2., -0.1, 0.2, 0.5, 0.2, -0.3, 0.1] + m = np.r_[-2., 1., 6., 2., -0.1, 0.2, 0.5, 0.2, -0.2, 0.2] self.assertTrue(mapping.test(m)) def test_transforms_logMap_reciprocalMap(self):