Skip to content
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
40 changes: 13 additions & 27 deletions gen_wrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,10 @@
NON_COPYABLE = ["ctx", "printer", "access_info"]
NON_COPYABLE_WITH_ISL_PREFIX = [f"isl_{i}" for i in NON_COPYABLE]

PYTHON_RESERVED_WORDS = """
and del from not while
as elif global or with
assert else if pass yield
break except import print
class exec in raise
continue finally is return
def for lambda try
""".split()
PYTHON_RESERVED_WORDS = ["and", "del", "from", "not", "while", "as", "elif", "global",
"or", "with", "assert", "else", "if", "pass", "yield", "break", "except", "import",
"print", "class", "exec", "in", "raise", "continue", "finally", "is", "return", "def",
"for", "lambda", "try"]
Comment on lines +55 to +58
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PYTHON_RESERVED_WORDS list has inconsistent formatting with line breaks in the middle of the list items. The list should either be formatted with proper line breaks and indentation for better readability, or kept on one line if it's not too long. As it stands, lines 55-58 have awkward line breaks that make it difficult to read. Consider reformatting this list to be more readable, such as one item per line or proper alignment.

Suggested change
PYTHON_RESERVED_WORDS = ["and", "del", "from", "not", "while", "as", "elif", "global",
"or", "with", "assert", "else", "if", "pass", "yield", "break", "except", "import",
"print", "class", "exec", "in", "raise", "continue", "finally", "is", "return", "def",
"for", "lambda", "try"]
PYTHON_RESERVED_WORDS = [
"and",
"del",
"from",
"not",
"while",
"as",
"elif",
"global",
"or",
"with",
"assert",
"else",
"if",
"pass",
"yield",
"break",
"except",
"import",
"print",
"class",
"exec",
"in",
"raise",
"continue",
"finally",
"is",
"return",
"def",
"for",
"lambda",
"try",
]

Copilot uses AI. Check for mistakes.


class Retry(RuntimeError): # noqa: N818
Expand All @@ -86,8 +81,7 @@ def to_py_class(cls: str):
if cls == "int":
return cls

if cls.startswith("isl_"):
cls = cls[4:]
cls = cls.removeprefix("isl_")

if cls == "ctx":
return "Context"
Expand All @@ -105,9 +99,7 @@ def to_py_class(cls: str):
else:
result += c

result = result.replace("Qpoly", "QPoly")

return result
return result.replace("Qpoly", "QPoly")


# {{{ data model
Expand Down Expand Up @@ -503,11 +495,9 @@ def get_preprocessed_header(self, fname: str) -> str:
self.get_header_contents(mh)
for mh in self.macro_headers]

prepro_header = preprocess_with_macros(
return preprocess_with_macros(
macro_header_contents, self.get_header_contents(fname))

return prepro_header

# {{{ read_header

def read_header(self, fname: str):
Expand Down Expand Up @@ -536,11 +526,8 @@ def read_header(self, fname: str):
while i < len(lines):
line = lines[i].strip()

if (not line
or line.startswith("extern")
or STRUCT_DECL_RE.search(line)
or line.startswith("typedef")
or line == "}"):
if (not line or line.startswith(("extern", "typedef"))
or STRUCT_DECL_RE.search(line) or line == "}"):
i += 1
elif "/*" in line:
while True:
Expand Down Expand Up @@ -661,7 +648,7 @@ def parse_decl(self, decl: str):
if name.startswith("options_"):
class_name = "ctx"
name = name[len("options_"):]
elif name.startswith("equality_") or name.startswith("inequality_"):
elif name.startswith(("equality_", "inequality_")):
class_name = "constraint"
elif name == "ast_op_type_set_print_name":
class_name = "printer"
Expand Down Expand Up @@ -697,7 +684,7 @@ def parse_decl(self, decl: str):
return

if class_name == "options":
assert name.startswith("set_") or name.startswith("get_"), (name, c_name)
assert name.startswith(("set_", "get_")), (name, c_name)
name = f"{name[:4]}option_{name[4:]}"

words = return_base_type.split()
Expand Down Expand Up @@ -1497,9 +1484,8 @@ def write_exposer(
if basic_cls == "basic_set":
if meth.name in ["is_params", "get_hash"]:
continue
elif basic_cls == "basic_map":
if meth.name in ["get_hash"]:
continue
elif basic_cls == "basic_map" and meth.name in ["get_hash"]:
continue

basic_overloads.append(meth)

Expand Down
4 changes: 2 additions & 2 deletions islpy/_monkeypatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@


if TYPE_CHECKING:
import islpy._isl as _isl
from islpy import _isl
else:
import sys
if "_isl" not in sys.modules:
import islpy._isl as _isl
from islpy import _isl
else:
# This is used for monkeypatching during stub generation.
# See stubgen/stubgen.py and CMakeLists for orchestration details.
Expand Down Expand Up @@ -851,7 +851,7 @@
"In particular, Spaces with matching names will no longer be "
"equal.")

return self.is_equal(other)

Check warning on line 854 in islpy/_monkeypatch.py

View workflow job for this annotation

GitHub Actions / Pytest Linux on Py3.10

Aff.is_equal with implicit conversion of self to PwAff is deprecated and will stop working in 2026. Explicitly convert to PwAff, using .to_pw_aff().

Check warning on line 854 in islpy/_monkeypatch.py

View workflow job for this annotation

GitHub Actions / Pytest Linux on Py3.10

Aff.is_equal with implicit conversion of self to PwAff is deprecated and will stop working in 2026. Explicitly convert to PwAff, using .to_pw_aff().

Check warning on line 854 in islpy/_monkeypatch.py

View workflow job for this annotation

GitHub Actions / Pytest Linux on Py3.10

Aff.is_equal with implicit conversion of self to PwAff is deprecated and will stop working in 2026. Explicitly convert to PwAff, using .to_pw_aff().

Check warning on line 854 in islpy/_monkeypatch.py

View workflow job for this annotation

GitHub Actions / Pytest Linux on Py3.10

Aff.is_equal with implicit conversion of self to PwAff is deprecated and will stop working in 2026. Explicitly convert to PwAff, using .to_pw_aff().


def obj_ne(self: object, other: object) -> bool:
Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ extend-ignore = [
"UP031", # use f-strings instead of %
"UP032", # use f-strings instead of .format
"RUF067", # no code in __init__ *shrug*
"TRY300",
"SIM102",
]

[tool.ruff.lint.flake8-quotes]
Expand All @@ -123,6 +125,10 @@ lines-after-imports = 2
"RUF012"
]

"test/test_*.py" = ["S102"]
"doc/conf.py" = ["S102"]
"gen_wrap.py" = ["SIM115"]

[tool.cibuildwheel]
# i686 does not have enough memory for LTO to complete
# 3.14 on musl has a hard-to-debug test crash
Expand Down
9 changes: 4 additions & 5 deletions stubgen/stubgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def main():
for fname in cast("list[str]", args.exec or []):
execdict = {"__name__": "islpy._monkeypatch"}
with open(fname) as inf:
exec(compile(inf.read(), fname, "exec"), execdict)
exec(compile(inf.read(), fname, "exec"), execdict) # noqa: S102

sg = StubGen(
module=mod,
Expand All @@ -75,10 +75,9 @@ def main():
include_docstrings=False,
)
sg.put(mod)
prefix_lines = "\n".join([
"from typing_extensions import Self",
"from collections.abc import Callable",
])
prefix_lines = (
"from typing_extensions import Self\n"
"from collections.abc import Callable")
with open(output_path / "_isl.pyi", "w") as outf:
outf.write(f"{prefix_lines}\n{sg.get()}")

Expand Down
6 changes: 2 additions & 4 deletions test/test_isl.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@

isl.PwAff(b)

assert b.is_equal(a)

Check warning on line 99 in test/test_isl.py

View workflow job for this annotation

GitHub Actions / Pytest macOS

Aff.is_equal with implicit conversion of self to PwAff is deprecated and will stop working in 2026. Explicitly convert to PwAff, using .to_pw_aff().

Check warning on line 99 in test/test_isl.py

View workflow job for this annotation

GitHub Actions / Pytest macOS

Aff.is_equal with implicit conversion of self to PwAff is deprecated and will stop working in 2026. Explicitly convert to PwAff, using .to_pw_aff().

Check warning on line 99 in test/test_isl.py

View workflow job for this annotation

GitHub Actions / Pytest Linux on Py3.12

Aff.is_equal with implicit conversion of self to PwAff is deprecated and will stop working in 2026. Explicitly convert to PwAff, using .to_pw_aff().

Check warning on line 99 in test/test_isl.py

View workflow job for this annotation

GitHub Actions / Pytest Linux on Py3.12

Aff.is_equal with implicit conversion of self to PwAff is deprecated and will stop working in 2026. Explicitly convert to PwAff, using .to_pw_aff().

Check warning on line 99 in test/test_isl.py

View workflow job for this annotation

GitHub Actions / Pytest Linux on Py3.x

Aff.is_equal with implicit conversion of self to PwAff is deprecated and will stop working in 2026. Explicitly convert to PwAff, using .to_pw_aff().

Check warning on line 99 in test/test_isl.py

View workflow job for this annotation

GitHub Actions / Pytest Linux on Py3.x

Aff.is_equal with implicit conversion of self to PwAff is deprecated and will stop working in 2026. Explicitly convert to PwAff, using .to_pw_aff().

Check warning on line 99 in test/test_isl.py

View workflow job for this annotation

GitHub Actions / Pytest Linux on Py3.10

Aff.is_equal with implicit conversion of self to PwAff is deprecated and will stop working in 2026. Explicitly convert to PwAff, using .to_pw_aff().

Check warning on line 99 in test/test_isl.py

View workflow job for this annotation

GitHub Actions / Pytest Linux on Py3.10

Aff.is_equal with implicit conversion of self to PwAff is deprecated and will stop working in 2026. Explicitly convert to PwAff, using .to_pw_aff().
assert a.is_equal(b)

s = isl.BasicSet("[n] -> {[i,j,k]: i<=j + k and (exists m: m=j+k) "
Expand All @@ -120,7 +120,7 @@
inst2 = loads(dumps(inst))

assert inst.space == inst2.space
assert inst.is_equal(inst2)

Check warning on line 123 in test/test_isl.py

View workflow job for this annotation

GitHub Actions / Pytest macOS

Aff.is_equal with implicit conversion of self to PwAff is deprecated and will stop working in 2026. Explicitly convert to PwAff, using .to_pw_aff().

Check warning on line 123 in test/test_isl.py

View workflow job for this annotation

GitHub Actions / Pytest macOS

Aff.is_equal with implicit conversion of self to PwAff is deprecated and will stop working in 2026. Explicitly convert to PwAff, using .to_pw_aff().

Check warning on line 123 in test/test_isl.py

View workflow job for this annotation

GitHub Actions / Pytest Linux on Py3.12

Aff.is_equal with implicit conversion of self to PwAff is deprecated and will stop working in 2026. Explicitly convert to PwAff, using .to_pw_aff().

Check warning on line 123 in test/test_isl.py

View workflow job for this annotation

GitHub Actions / Pytest Linux on Py3.12

Aff.is_equal with implicit conversion of self to PwAff is deprecated and will stop working in 2026. Explicitly convert to PwAff, using .to_pw_aff().

Check warning on line 123 in test/test_isl.py

View workflow job for this annotation

GitHub Actions / Pytest Linux on Py3.x

Aff.is_equal with implicit conversion of self to PwAff is deprecated and will stop working in 2026. Explicitly convert to PwAff, using .to_pw_aff().

Check warning on line 123 in test/test_isl.py

View workflow job for this annotation

GitHub Actions / Pytest Linux on Py3.x

Aff.is_equal with implicit conversion of self to PwAff is deprecated and will stop working in 2026. Explicitly convert to PwAff, using .to_pw_aff().

Check warning on line 123 in test/test_isl.py

View workflow job for this annotation

GitHub Actions / Pytest Linux on Py3.10

Aff.is_equal with implicit conversion of self to PwAff is deprecated and will stop working in 2026. Explicitly convert to PwAff, using .to_pw_aff().

Check warning on line 123 in test/test_isl.py

View workflow job for this annotation

GitHub Actions / Pytest Linux on Py3.10

Aff.is_equal with implicit conversion of self to PwAff is deprecated and will stop working in 2026. Explicitly convert to PwAff, using .to_pw_aff().


def test_apostrophes_during_pickling():
Expand Down Expand Up @@ -209,7 +209,7 @@

def callback(node, build):
schedulemap = build.get_schedule()
accessmap = accesses.apply_domain(schedulemap)

Check warning on line 212 in test/test_isl.py

View workflow job for this annotation

GitHub Actions / Pytest macOS

Map.apply_domain with implicit conversion of self to UnionMap is deprecated and will stop working in 2026. Explicitly convert to UnionMap, using .to_union_map().

Check warning on line 212 in test/test_isl.py

View workflow job for this annotation

GitHub Actions / Pytest macOS

Map.apply_domain with implicit conversion of self to UnionMap is deprecated and will stop working in 2026. Explicitly convert to UnionMap, using .to_union_map().

Check warning on line 212 in test/test_isl.py

View workflow job for this annotation

GitHub Actions / Pytest Linux on Py3.12

Map.apply_domain with implicit conversion of self to UnionMap is deprecated and will stop working in 2026. Explicitly convert to UnionMap, using .to_union_map().

Check warning on line 212 in test/test_isl.py

View workflow job for this annotation

GitHub Actions / Pytest Linux on Py3.12

Map.apply_domain with implicit conversion of self to UnionMap is deprecated and will stop working in 2026. Explicitly convert to UnionMap, using .to_union_map().

Check warning on line 212 in test/test_isl.py

View workflow job for this annotation

GitHub Actions / Pytest Linux on Py3.x

Map.apply_domain with implicit conversion of self to UnionMap is deprecated and will stop working in 2026. Explicitly convert to UnionMap, using .to_union_map().

Check warning on line 212 in test/test_isl.py

View workflow job for this annotation

GitHub Actions / Pytest Linux on Py3.x

Map.apply_domain with implicit conversion of self to UnionMap is deprecated and will stop working in 2026. Explicitly convert to UnionMap, using .to_union_map().

Check warning on line 212 in test/test_isl.py

View workflow job for this annotation

GitHub Actions / Pytest Linux on Py3.10

Map.apply_domain with implicit conversion of self to UnionMap is deprecated and will stop working in 2026. Explicitly convert to UnionMap, using .to_union_map().

Check warning on line 212 in test/test_isl.py

View workflow job for this annotation

GitHub Actions / Pytest Linux on Py3.10

Map.apply_domain with implicit conversion of self to UnionMap is deprecated and will stop working in 2026. Explicitly convert to UnionMap, using .to_union_map().
aff = isl.PwMultiAff.from_map(isl.Map.from_union_map(accessmap))
access = build.call_from_pw_multi_aff(aff)
return isl.AstNode.alloc_user(access)
Expand All @@ -220,13 +220,11 @@

def cb_print_user(printer, options, node):
print("Callback user called")
printer = printer.print_str("Callback user")
return printer
return printer.print_str("Callback user")

def cb_print_for(printer, options, node):
print("Callback for called")
printer = printer.print_str("Callback For")
return printer
return printer.print_str("Callback For")

opts = isl.AstPrintOptions.alloc(isl.DEFAULT_CONTEXT)
opts, _cb_print_user_handle = opts.set_print_user(cb_print_user)
Expand Down
Loading