Skip to content

Commit e4ae4c9

Browse files
committed
Fix conversions
1 parent abf6db9 commit e4ae4c9

File tree

2 files changed

+12
-27
lines changed

2 files changed

+12
-27
lines changed

sumpy/codegen.py

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232

3333
from pytools import memoize_method
3434

35-
from sumpy.symbolic import (SympyToPymbolicMapper as SympyToPymbolicMapperBase)
35+
from sumpy.symbolic import SympyToPymbolicMapper
36+
import sumpy.symbolic as sym
3637

3738
import logging
3839
logger = logging.getLogger(__name__)
@@ -49,27 +50,6 @@
4950
"""
5051

5152

52-
# {{{ sympy -> pymbolic mapper
53-
54-
import sumpy.symbolic as sym
55-
_SPECIAL_FUNCTION_NAMES = frozenset(dir(sym.functions))
56-
57-
58-
class SympyToPymbolicMapper(SympyToPymbolicMapperBase):
59-
60-
def not_supported(self, expr):
61-
if isinstance(expr, int):
62-
return expr
63-
elif getattr(expr, "is_Function", False):
64-
func_name = SympyToPymbolicMapperBase.function_name(self, expr)
65-
return prim.Variable(func_name)(
66-
*tuple(self.rec(arg) for arg in expr.args))
67-
else:
68-
return SympyToPymbolicMapperBase.not_supported(self, expr)
69-
70-
# }}}
71-
72-
7353
# {{{ bessel -> loopy codegen
7454

7555
BESSEL_PREAMBLE = """//CL//

sumpy/symbolic.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -313,12 +313,17 @@ def map_Mul(self, expr): # noqa: N802
313313

314314
return math.prod(num_args) / math.prod(den_args)
315315

316-
def map_FunctionSymbol(self, expr):
317-
if expr.get_name() == "ExpI":
318-
arg = self.rec(expr.args[0])
319-
return prim.Variable("cos")(arg) + 1j * prim.Variable("sin")(arg)
316+
def not_supported(self, expr):
317+
print(expr)
318+
if getattr(expr, "is_Function", False):
319+
if self.function_name(expr) == "ExpI":
320+
arg = self.rec(expr.args[0])
321+
return prim.Variable("cos")(arg) + 1j * prim.Variable("sin")(arg)
322+
else:
323+
return prim.Variable(self.function_name(expr))(
324+
*[self.rec(arg) for arg in expr.args])
320325
else:
321-
return SympyToPymbolicMapperBase.map_FunctionSymbol(self, expr)
326+
return SympyToPymbolicMapperBase.not_supported(self, expr)
322327

323328

324329
class PymbolicToSympyMapperWithSymbols(PymbolicToSympyMapper):

0 commit comments

Comments
 (0)