From f90637509e4f203677ca28491de8b498179749ee Mon Sep 17 00:00:00 2001 From: Lindsey Date: Mon, 1 Jun 2015 16:07:05 -0700 Subject: [PATCH 1/3] Fields takes srcList --- SimPEG/Fields.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/SimPEG/Fields.py b/SimPEG/Fields.py index 1801bedc..d9da317d 100644 --- a/SimPEG/Fields.py +++ b/SimPEG/Fields.py @@ -141,11 +141,8 @@ class Fields(object): # Aliased fields alias, loc, func = self.aliasFields[name] - srcII = np.array(self.survey.srcList)[ind] - if isinstance(srcII, np.ndarray): - srcII = srcII.tolist() - if len(srcII) == 1: - srcII = srcII[0] + srcII = np.array(self.survey.srcList)[ind] + srcII = srcII.tolist() if type(func) is str: assert hasattr(self, func), 'The alias field function is a string, but it does not exist in the Fields class.' From 4df383ccec5c745c81036dc7e407c648fd035c4c Mon Sep 17 00:00:00 2001 From: Lindsey Date: Mon, 1 Jun 2015 16:17:05 -0700 Subject: [PATCH 2/3] fixed test_Fields --- SimPEG/Tests/test_Fields.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SimPEG/Tests/test_Fields.py b/SimPEG/Tests/test_Fields.py index 22189a15..bd75d712 100644 --- a/SimPEG/Tests/test_Fields.py +++ b/SimPEG/Tests/test_Fields.py @@ -147,7 +147,7 @@ class FieldsTest_Alias(unittest.TestCase): def test_aliasFunction(self): def alias(e, ind): - self.assertTrue(ind is self.Src0) + self.assertTrue(ind[0] is self.Src0) return self.F.mesh.edgeCurl * e F = Problem.Fields(self.F.mesh, self.F.survey, knownFields={'e':'E'}, aliasFields={'b':['e','F',alias]}) e = np.random.rand(F.mesh.nE,1) From 5caf2371212f27adea43b65a44db400bf6d8c27d Mon Sep 17 00:00:00 2001 From: Rowan Cockett Date: Mon, 1 Jun 2015 16:27:31 -0700 Subject: [PATCH 3/3] updates to the time fields side of things as well --- SimPEG/Fields.py | 7 ++----- SimPEG/Tests/test_Fields.py | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/SimPEG/Fields.py b/SimPEG/Fields.py index d9da317d..9baa32f8 100644 --- a/SimPEG/Fields.py +++ b/SimPEG/Fields.py @@ -235,11 +235,8 @@ class TimeFields(Fields): pointerFields = pointerFields.reshape(pointerShape, order='F') timeII = np.arange(self.survey.prob.nT + 1)[timeInd] - srcII = np.array(self.survey.srcList)[srcInd] - if isinstance(srcII, np.ndarray): - srcII = srcII.tolist() - if len(srcII) == 1: - srcII = srcII[0] + srcII = np.array(self.survey.srcList)[srcInd] + srcII = srcII.tolist() if timeII.size == 1: pointerShapeDeflated = self._correctShape(alias, ind, deflate=True) diff --git a/SimPEG/Tests/test_Fields.py b/SimPEG/Tests/test_Fields.py index bd75d712..629189b8 100644 --- a/SimPEG/Tests/test_Fields.py +++ b/SimPEG/Tests/test_Fields.py @@ -343,7 +343,7 @@ class FieldsTest_Time_Aliased(unittest.TestCase): count = [0] def alias(e, srcInd, timeInd): count[0] += 1 - self.assertTrue(srcInd is self.Src0) + self.assertTrue(srcInd[0] is self.Src0) return self.F.mesh.edgeCurl * e F = Problem.TimeFields(self.F.mesh, self.F.survey, knownFields={'e':'E'}, aliasFields={'b':['e','F',alias]}) e = np.random.rand(F.mesh.nE,1,nT)