def test_ast_convertion(self, equation, expected): """ Test OPS generated expressions for 1, 2 and 3 space dimensions. Parameters ---------- equation : str A string with a :class:`Eq`to be evaluated. expected : str Expected expression to be generated from devito. """ grid_1d = Grid(shape=(4)) grid_2d = Grid(shape=(4, 4)) grid_3d = Grid(shape=(4, 4, 4)) a = 1.43 # noqa b = 0.000000987 # noqa c = 999999999999999 # noqa u = TimeFunction(name='u', grid=grid_1d, space_order=2) # noqa v = TimeFunction(name='v', grid=grid_2d, space_order=2) # noqa w = TimeFunction(name='w', grid=grid_3d, space_order=2) # noqa nfops = OPSNodeFactory() result = make_ops_ast(indexify(eval(equation).evaluate), nfops) assert str(result) == expected
def test_ast_convertion(self, equation, expected): """ Test OPS generated expressions for 1, 2 and 3 space dimensions. Parameters ---------- equation : str A string with a :class:`Eq`to be evaluated. expected : str Expected expression to be generated from devito. """ grid_1d = Grid(shape=(4)) grid_2d = Grid(shape=(4, 4)) grid_3d = Grid(shape=(4, 4, 4)) a = 1.43 # noqa b = 0.000000987 # noqa c = 999999999999999 # noqa u = TimeFunction(name='u', grid=grid_1d, space_order=2) # noqa v = TimeFunction(name='v', grid=grid_2d, space_order=2) # noqa w = TimeFunction(name='w', grid=grid_3d, space_order=2) # noqa nfops = OPSNodeFactory() result = make_ops_ast(indexify(eval(equation)), nfops) assert str(result) == expected
def test_accesses_extraction(self, equation, expected): grid_1d = Grid(shape=(4)) grid_3d = Grid(shape=(4, 4, 4)) a = 1.43 # noqa c = 999999999999999 # noqa u = TimeFunction(name='u', grid=grid_1d, space_order=2) # noqa v = TimeFunction(name='v', grid=grid_1d, space_order=2) # noqa w = TimeFunction(name='w', grid=grid_3d, space_order=2) # noqa node_factory = OPSNodeFactory() make_ops_ast(indexify(eval(equation).evaluate), node_factory) result = eval(expected) for k, v in node_factory.ops_args_accesses.items(): assert len(v) == len(result[k.name]) for idx in result[k.name]: assert idx in v