Skip to content

Commit

Permalink
Do not import @types and @template in every generated module
Browse files Browse the repository at this point in the history
  • Loading branch information
yguclu committed Oct 27, 2023
1 parent a83450b commit 0ffcb2a
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions psydac/api/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,20 +227,22 @@ def _initialize_folder(self, folder=None):
return folder

def _generate_code(self):
# ... generate code that can be pyccelized
imports = ''

if self.backend['name'] == 'pyccel':
imports = "from pyccel.decorators import types"
imports += ", template \n@template(name='T', types=['float', 'complex']) "

ast = self.ast
expr = parse(ast.expr, settings={'dim': ast.dim, 'nderiv': ast.nderiv, 'mapping':ast.mapping, 'target':ast.domain}, backend=self.backend)

dep = pycode(expr)
code = f'{imports}\n{dep}'

return code
"""
Generate Python code which can be pyccelized.
"""
psydac_ast = self.ast

parser_settings = {
'dim' : psydac_ast.dim,
'nderiv' : psydac_ast.nderiv,
'mapping': psydac_ast.mapping,
'target' : psydac_ast.domain
}

pyccel_ast = parse(psydac_ast.expr, settings=parser_settings, backend=self.backend)
python_code = pycode(pyccel_ast)

return python_code

def _save_code(self, code, backend=None):
# ...
Expand Down

0 comments on commit 0ffcb2a

Please sign in to comment.