mirror of
https://github.com/wassname/simpeg.git
synced 2026-07-02 05:16:36 +08:00
Working on making fields 1 wide in Problem.mp
This commit is contained in:
+3
-3
@@ -139,7 +139,7 @@ class Fields(object):
|
||||
return self._getField(name, ind)
|
||||
|
||||
def _setField(self, field, val, name, ind):
|
||||
if isinstance(val, np.ndarray) and (field.shape[1] == 1 or val.ndim == 1):
|
||||
if isinstance(val, np.ndarray) and (field.shape[0] == field.size or val.ndim == 1):
|
||||
val = Utils.mkvc(val,2)
|
||||
field[:,ind] = val
|
||||
|
||||
@@ -160,8 +160,8 @@ class Fields(object):
|
||||
assert hasattr(self, func), 'The alias field function is a string, but it does not exist in the Fields class.'
|
||||
func = getattr(self, func)
|
||||
out = func(self._fields[alias][:,ind], srcII)
|
||||
if out.shape[0] == out.size:
|
||||
out = Utils.mkvc(out)
|
||||
if isinstance(out, np.ndarray) and (out.shape[0] == out.size or out.ndim == 1):
|
||||
out = Utils.mkvc(out,2)
|
||||
return out
|
||||
|
||||
def __contains__(self, other):
|
||||
|
||||
@@ -80,9 +80,9 @@ class DataAndFieldsTest(unittest.TestCase):
|
||||
|
||||
b = np.random.rand(F.mesh.nF,1)
|
||||
F[self.Src0, 'b'] = b
|
||||
self.assertTrue(np.all(F[self.Src0, 'b'] == Utils.mkvc(b)))
|
||||
self.assertTrue(np.all(F[self.Src0, 'b'] == b))
|
||||
|
||||
b = np.random.rand(F.mesh.nF)
|
||||
b = np.random.rand(F.mesh.nF,1)
|
||||
F[self.Src0, 'b'] = b
|
||||
self.assertTrue(np.all(F[self.Src0, 'b'] == b))
|
||||
|
||||
@@ -96,8 +96,8 @@ class DataAndFieldsTest(unittest.TestCase):
|
||||
|
||||
b = np.random.rand(F.mesh.nF, 2)
|
||||
F[[self.Src0, self.Src1],'b'] = b
|
||||
self.assertTrue(F[self.Src0]['b'].shape == (F.mesh.nF,))
|
||||
self.assertTrue(F[self.Src0,'b'].shape == (F.mesh.nF,))
|
||||
self.assertTrue(F[self.Src0]['b'].shape == (F.mesh.nF,1))
|
||||
self.assertTrue(F[self.Src0,'b'].shape == (F.mesh.nF,1))
|
||||
self.assertTrue(np.all(F[self.Src0,'b'] == b[:,0]))
|
||||
self.assertTrue(np.all(F[self.Src1,'b'] == b[:,1]))
|
||||
|
||||
@@ -158,7 +158,7 @@ class FieldsTest_Alias(unittest.TestCase):
|
||||
|
||||
e = np.random.rand(F.mesh.nE,1)
|
||||
F[self.Src0, 'e'] = e
|
||||
self.assertTrue(np.all(F[self.Src0, 'b'] == F.mesh.edgeCurl * Utils.mkvc(e)))
|
||||
self.assertTrue(np.all(F[self.Src0, 'b'] == F.mesh.edgeCurl * e))
|
||||
|
||||
def f():
|
||||
F[self.Src0, 'b'] = F[self.Src0, 'b']
|
||||
|
||||
Reference in New Issue
Block a user