Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

Commit

Permalink
Fix creation of operator ASTs
Browse files Browse the repository at this point in the history
  • Loading branch information
FabioLuporini authored and Gheorghe-Teodor Bercea committed Mar 24, 2015
1 parent e230403 commit e84f026
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions pyop2/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1990,10 +1990,10 @@ def _check_shape(self, other):
self.dataset.dim, other.dataset.dim)

def _op(self, other, op):
ops = {operator.add: '+',
operator.sub: '-',
operator.mul: '*',
operator.div: '/'}
ops = {operator.add: ast.Sum,
operator.sub: ast.Sub,
operator.mul: ast.Prod,
operator.div: ast.Div}
ret = _make_object('Dat', self.dataset, None, self.dtype)
name = "binop_%s" % op.__name__
if np.isscalar(other):
Expand All @@ -2006,9 +2006,8 @@ def _op(self, other, op):
ast.Decl(self.ctype, ast.Symbol("*ret"))],
ast.c_for("n", self.cdim,
ast.Assign(ast.Symbol("ret", ("n", )),
ast.BinExpr(ast.Symbol("self", ("n", )),
ast.Symbol("other", ("0", )),
op=ops[op])),
ops[op](ast.Symbol("self", ("n", )),
ast.Symbol("other", ("0", )))),
pragma=None))

k = _make_object('Kernel', k, name)
Expand All @@ -2022,9 +2021,8 @@ def _op(self, other, op):
ast.Decl(self.ctype, ast.Symbol("*ret"))],
ast.c_for("n", self.cdim,
ast.Assign(ast.Symbol("ret", ("n", )),
ast.BinExpr(ast.Symbol("self", ("n", )),
ast.Symbol("other", ("n", )),
op=ops[op])),
ops[op](ast.Symbol("self", ("n", )),
ast.Symbol("other", ("n", )))),
pragma=None))

k = _make_object('Kernel', k, name)
Expand Down

0 comments on commit e84f026

Please sign in to comment.