Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pymbolic typing #98

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions modepy/modes.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ def _cse(expr, prefix):
def _where(op_a, comp, op_b, then, else_):
from pymbolic.primitives import Comparison, Expression, If
if isinstance(op_a, Expression) or isinstance(op_b, Expression):
return If(Comparison(op_a, comp, op_b), then, else_)
return If(
Comparison(op_a, Comparison.name_to_operator[comp], op_b),
then, else_)

import operator
comp_op = getattr(operator, comp)
Expand Down Expand Up @@ -203,7 +205,7 @@ def jacobi(alpha: float, beta: float, n: int, x: RealValueT) -> RealValueT:

bnew = -(alpha*alpha-beta*beta)/(h1*(h1+2.))
pl.append(_cse(
(-aold*pl[i-1] + np.multiply(x-bnew, pl[i]))/anew,
(-aold*pl[i-1] + (x-bnew) * pl[i])/anew,
prefix=f"jac_p{i+1}"))
aold = anew

Expand Down
Loading