name slicing in fancy fields

This commit is contained in:
rowanc1
2014-04-26 18:09:02 -07:00
parent df3ba5f8ee
commit 6e3d3863c1
2 changed files with 16 additions and 11 deletions
+4 -4
View File
@@ -20,7 +20,7 @@ class DataAndFieldsTest(unittest.TestCase):
txList = [Tx0,Tx1,Tx2,Tx3,Tx4]
survey = Survey.BaseSurvey(txList=txList)
self.D = Survey.Data(survey)
self.F = Survey.Fields(mesh, survey, knownFields={'phi':'CC','e':'E','b':'F'})
self.F = Survey.Fields(mesh, survey, knownFields={'phi':'CC','e':'E','b':'F'}, dtype={"phi":float,"e":complex,"b":complex})
self.Tx0 = Tx0
self.Tx1 = Tx1
self.mesh = mesh
@@ -49,9 +49,9 @@ class DataAndFieldsTest(unittest.TestCase):
def test_SetGet(self):
F = self.F
nTx = F.survey.nTx
e = np.random.rand(F.mesh.nE, nTx)
e = np.random.rand(F.mesh.nE, nTx) + np.random.rand(F.mesh.nE, nTx)*1j
F[:, 'e'] = e
b = np.random.rand(F.mesh.nF, nTx)
b = np.random.rand(F.mesh.nF, nTx) + np.random.rand(F.mesh.nF, nTx)*1j
F[:, 'b'] = b
self.assertTrue(np.all(F[:, 'e'] == e))
@@ -72,7 +72,7 @@ class DataAndFieldsTest(unittest.TestCase):
F[[self.Tx0,self.Tx1], 'phi'] = phi
self.assertTrue(np.all(F[[self.Tx0,self.Tx1], 'phi'] == phi))
fdict = F[:]
fdict = F[:,:]
self.assertTrue(type(fdict) is dict)
self.assertTrue(sorted([k for k in fdict]) == ['b','e','phi'])