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

Improve to_identifier #261

Merged
merged 1 commit into from
May 21, 2024
Merged
Show file tree
Hide file tree
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
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
Loading