Esempio n. 1
0
 def test_explicit_run(self):
     time_dim = 6
     grid = Grid(shape=(11, 11))
     a = TimeFunction(name='a', grid=grid, time_order=1, save=time_dim)
     eqn = Eq(a.forward, a + 1.)
     op = Operator(eqn)
     assert isinstance(op, OperatorForeign)
     args = OrderedDict(op.arguments())
     assert args['a'] is None
     # Emulate data feeding from outside
     array = np.ndarray(shape=a.shape, dtype=np.float32)
     array.fill(0.0)
     args['a'] = array
     op.cfunction(*list(args.values()))
     assert all(np.allclose(args['a'][i], i) for i in range(time_dim))
Esempio n. 2
0
 def test_code(self):
     shape = (11, 11)
     a = TimeData(name='a',
                  shape=shape,
                  time_order=1,
                  time_dim=6,
                  save=True)
     eqn = Eq(a.forward, a + 1.)
     b = TimeData(name='a',
                  shape=shape,
                  time_order=1,
                  time_dim=6,
                  save=True)
     eqn2 = Eq(b.forward, b + 1.)
     op = Operator(eqn)
     op()
     op2 = Operator(eqn2, external=True)
     arg, _ = op.arguments(a=b)
     op2.cfunction(*list(arg.values()))
     assert (np.allclose(a.data[:], b.data[:]))