Skip to content

Commit

Permalink
Improve to_identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasdiener authored and inducer committed May 21, 2024
1 parent 146c598 commit 325f56e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
12 changes: 4 additions & 8 deletions arraycontext/impl/pytato/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
from immutabledict import immutabledict

import pytato as pt
from pytools import ProcessLogger
from pytools import ProcessLogger, to_identifier
from pytools.tag import Tag

from arraycontext.container import ArrayContainer, is_array_container_type
Expand All @@ -52,19 +52,15 @@
logger = logging.getLogger(__name__)


def _to_identifier(s: str) -> str:
return "".join(ch for ch in s if ch.isidentifier())


def _prg_id_to_kernel_name(f: Any) -> str:
if callable(f):
name = getattr(f, "__name__", "<anonymous>")
name = getattr(f, "__name__", "anonymous")
if not name.isidentifier():
return "actx_compiled_" + _to_identifier(name)
return "actx_compiled_" + to_identifier(name)
else:
return name
else:
return _to_identifier(str(f))
return to_identifier(str(f))


class FromArrayContextCompile(Tag):
Expand Down
4 changes: 1 addition & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ def main():
python_requires="~=3.8",
install_requires=[
"numpy",

# https://github.com/inducer/arraycontext/pull/147
"pytools>=2022.1.3",
"pytools>=2024.1.3",
"immutabledict",
"loopy>=2019.1",
],
Expand Down

0 comments on commit 325f56e

Please sign in to comment.