Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
34041c0
add named Set and Map creation
a-alveyblanc Dec 19, 2025
7d57de2
implement joint name to dim finding based on alphabetical ordering wi…
a-alveyblanc Jan 11, 2026
6b792d0
use dataclasses for namedisl objects
a-alveyblanc Jan 12, 2026
4771dad
remove unclear FIXME
a-alveyblanc Jan 12, 2026
d9849ec
reorder dimension type-chunk movement
a-alveyblanc Jan 13, 2026
65301c1
refactor dimension type tracking for reconstruction; undo joint name …
a-alveyblanc Jan 15, 2026
5ad094d
address ruff + basedpyright complaints
a-alveyblanc Jan 15, 2026
727f18c
joint ordering and alignment v0.1 implementation
a-alveyblanc Jan 15, 2026
dcdcb20
address ruff + basedpyright complaints
a-alveyblanc Jan 15, 2026
564e6b3
Merge branch 'main' of github.com:inducer/namedisl into initial-funct…
a-alveyblanc Jan 15, 2026
491e5fb
implement alignment, setlike operations, setlike tests
a-alveyblanc Jan 19, 2026
40526fb
fix test utils bug; get tests for setlikes passing
a-alveyblanc Jan 20, 2026
8788935
typing changes to be consistent with other packages + minor refactoring
a-alveyblanc Jan 20, 2026
981a176
major refactor of __init__ into different files to improve structure;…
a-alveyblanc Jan 20, 2026
4e0c8b3
Merge branch 'main' of github.com:inducer/namedisl into initial-funct…
a-alveyblanc Jan 20, 2026
dfc5ade
add expression-likes necessary for set-like operations; basedpyright …
a-alveyblanc Jan 26, 2026
fe40431
add tests for expression-likes; add qpolynomials; refactor
a-alveyblanc Jan 30, 2026
d848454
address pylint concerns
a-alveyblanc Jan 30, 2026
157e119
address ruff concerns; leaving basedpyright + docs failing for now
a-alveyblanc Jan 30, 2026
2f1eff0
Toward type happiness?
inducer Feb 2, 2026
4c397ee
toward making basedpyright happy
a-alveyblanc Feb 16, 2026
7c97d5c
add property for getting names
a-alveyblanc Feb 16, 2026
4d5555c
formatting fix
a-alveyblanc Feb 16, 2026
1f33281
make {_input, _parameter}_names public
a-alveyblanc Feb 16, 2026
12230ae
fix repo corruption
a-alveyblanc Mar 10, 2026
6841aba
Fix ruff
inducer Mar 10, 2026
fffd775
Fix typing of _align_and_apply_binary_op
inducer Mar 10, 2026
80f3818
Don't use len in emptiness checks
inducer Mar 10, 2026
bc9d2af
use codex to debug, add new features
a-alveyblanc Apr 6, 2026
1148097
tighten abstraction, add more features to set-likes
a-alveyblanc Apr 16, 2026
27d46eb
clean up typing
a-alveyblanc Apr 22, 2026
90ab98c
some chunking + typing fixes
a-alveyblanc Apr 23, 2026
26a4f8a
more setlike operations, tests
a-alveyblanc May 19, 2026
dd2885e
make basedpyright happy
a-alveyblanc May 21, 2026
db4c317
make ruff happy
a-alveyblanc May 21, 2026
6360261
remove some dead code; remove temporary tests that imported loopy and…
a-alveyblanc May 21, 2026
006b129
pylint related fixes
a-alveyblanc May 21, 2026
97a0a87
add docs; more typechecker/linter fixes
a-alveyblanc May 21, 2026
c1c8424
configure docs
a-alveyblanc May 21, 2026
6d695e1
make NamedIslObject (and subclasses) vary over internal and public IS…
a-alveyblanc May 26, 2026
d980b5f
fix conflicting, cross-dimension name handling; other minor fixes
a-alveyblanc May 26, 2026
7ee2e65
check that names exist before operating; Multi expression overhaul
a-alveyblanc Jun 9, 2026
95328a1
Make MultiExpressionLikes store named parts
a-alveyblanc Jun 10, 2026
aa393de
Make multi objects container-like data structures separate from Named…
a-alveyblanc Jun 10, 2026
89b020b
fix ruff complaint
a-alveyblanc Jun 10, 2026
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ distribute*tar.gz

.pylintrc.yml
.run-pylint.py

.codex
34 changes: 20 additions & 14 deletions doc/conf.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,37 @@
from __future__ import annotations

import sys
from importlib import metadata
from pathlib import Path
from urllib.request import urlopen


_conf_url = \
"https://raw.githubusercontent.com/inducer/sphinxconfig/main/sphinxconfig.py"
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))

_conf_url = "https://tiker.net/sphinxconfig-v0.py"
with urlopen(_conf_url) as _inf:
exec(compile(_inf.read(), _conf_url, "exec"), globals())

Comment on lines +11 to 14
copyright = "2025- University of Illiois Board of Trustees"
author = "Andreas Kloeckner"
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.intersphinx",
"sphinx.ext.linkcode",
]

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
ver_dic = {}
with open("../namedisl/__init__.py") as vfile:
exec(compile(vfile.read(), "../namedisl/__init__.py", "exec"), ver_dic)
autodoc_member_order = "bysource"
autodoc_typehints = "none"

project = "namedisl"
copyright = "2025- University of Illinois Board of Trustees"
author = "Andreas Kloeckner"

version = ".".join(str(x) for x in ver_dic["__version__"])
release = ver_dic["__version__"]
release = metadata.version("namedisl")
version = ".".join(release.split(".")[:2])

intersphinx_mapping = {
"islpy": ("https://documen.tician.de/islpy", None),
"constantdict": ("https://matthiasdiener.github.io/constantdict/", None),
"python": ("https://docs.python.org/3", None),
}

nitpicky = True
6 changes: 6 additions & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
Welcome to namedisl's documentation!
====================================

namedisl is a small wrapper around :mod:`islpy` for code that needs dimension
names to carry semantic meaning. It keeps isl's integer-set operations while
offering a name-oriented interface for sets, maps, affine expressions, and
piecewise affine expressions.

.. toctree::
:maxdepth: 2
:caption: Contents:

ref
internals

🚀 Github <https://github.com/inducer/namedisl>
💾 Download Releases <https://pypi.org/project/namedisl>
Expand Down
18 changes: 18 additions & 0 deletions doc/internals.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Internal Reference
==================

These interfaces support the public wrappers and are mainly useful when
maintaining namedisl itself.

.. automodule:: namedisl.core

.. autoclass:: namedisl.core.NamedIslObject
:members:

.. autofunction:: namedisl.core._deconstruct_object

.. autofunction:: namedisl.core._make_named_object_pieces

.. autofunction:: namedisl.core._align_two

.. autofunction:: namedisl.core._align_and_apply_binary_op
86 changes: 86 additions & 0 deletions doc/ref.rst

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Maybe keep the top-level .rsts to only module references?

Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,89 @@ Reference
=========

.. automodule:: namedisl

Set and Map Objects
-------------------

.. autofunction:: make_basic_set

.. autofunction:: make_set

.. autofunction:: make_basic_map

.. autofunction:: make_map

.. autofunction:: make_map_from_domain_and_range

.. autoclass:: BasicSet
:members:
:inherited-members:
:special-members: __and__, __or__, __sub__, __lt__, __le__, __gt__, __ge__
:exclude-members: __init__, __new__

.. autoclass:: Set
:members:
:inherited-members:
:special-members: __and__, __or__, __sub__, __lt__, __le__, __gt__, __ge__
:exclude-members: __init__, __new__

.. autoclass:: BasicMap
:members:
:inherited-members:
:special-members: __and__, __or__, __sub__, __lt__, __le__, __gt__, __ge__
:exclude-members: __init__, __new__

.. autoclass:: Map
:members:
:inherited-members:
:special-members: __and__, __or__, __sub__, __lt__, __le__, __gt__, __ge__
:exclude-members: __init__, __new__

Expression Objects
------------------

.. autofunction:: make_aff

.. autofunction:: make_pw_aff

.. autofunction:: make_qpolynomial

.. autofunction:: make_pw_qpolynomial

.. autofunction:: make_multi_aff

.. autofunction:: make_pw_multi_aff

.. autoclass:: Aff
:members:
:inherited-members:
:special-members: __add__, __sub__, __mul__
:exclude-members: __init__, __new__

.. autoclass:: PwAff
:members:
:inherited-members:
:special-members: __add__, __sub__, __mul__
:exclude-members: __init__, __new__

.. autoclass:: QPolynomial
:members:
:inherited-members:
:special-members: __add__, __sub__, __mul__
:exclude-members: __init__, __new__

.. autoclass:: PwQPolynomial
:members:
:inherited-members:
:special-members: __add__, __sub__, __mul__
:exclude-members: __init__, __new__

.. autoclass:: MultiAff
:members:
:inherited-members:
:exclude-members: __init__, __new__

.. autoclass:: PwMultiAff
:members:
:inherited-members:
:exclude-members: __init__, __new__
132 changes: 59 additions & 73 deletions namedisl/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
"""
.. autoclass:: BasicSet
Name-aware wrappers for :mod:`islpy` objects.

.. autofunction:: make_basic_set
"""
namedisl offers small Python wrappers around isl sets, maps, and expression
objects. The wrappers keep a separate mapping from dimension names to isl
dimension positions, align operands by name before applying binary operations,
and reconstruct ordinary :mod:`islpy` objects when callers need to interoperate
with islpy or downstream libraries.

Most users should construct objects through the ``make_*`` functions exported
from this module.
"""

from __future__ import annotations

Expand Down Expand Up @@ -31,74 +37,54 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"""
import re
from collections.abc import Mapping
from dataclasses import dataclass
from importlib import metadata
from typing import TypeAlias, TypeVar, overload

from constantdict import constantdict
from typing_extensions import override

import islpy as isl


__version__ = metadata.version("namedisl")
_match = re.match(r"^([0-9.]+)([a-z0-9]*?)$", __version__)
assert _match
VERSION = tuple(int(nr) for nr in _match.group(1).split("."))


IslObject = TypeVar("IslObject", isl.BasicSet, isl.Set)
NameToDim: TypeAlias = Mapping[str, tuple[isl.dim_type, int]]


def _strip_names(obj: IslObject) -> tuple[IslObject, NameToDim]:
name_to_dim: dict[str, tuple[isl.dim_type, int]] = {}
for tp in isl._CHECK_DIM_TYPES:
for i in range(obj.dim(tp)):
name = obj.get_dim_name(tp, i)
if name is None:
raise ValueError("unnamed dimension found")
if name in name_to_dim:
raise ValueError(f"non-unique dim name: {name}")
name_to_dim[name] = (tp, i)

# FIXME: Enable, to avoid misunderstandings
# obj = obj.set_dim_id(tp, i, None)

return obj, constantdict(name_to_dim)


def _restore_names(obj: IslObject, name_to_dim: NameToDim) -> IslObject:
for name, (dt, i) in name_to_dim.items():
obj = obj.set_dim_name(dt, i, name)

return obj


@dataclass(frozen=True)
class BasicSet:
_obj: isl.BasicSet
_name_to_dim: NameToDim

@override
def __str__(self) -> str:
return str(_restore_names(self._obj, self._name_to_dim))


@overload
def make_basic_set(src: str, ctx: isl.Context | None = None) -> BasicSet:
...


@overload
def make_basic_set(src: isl.BasicSet) -> BasicSet:
...


def make_basic_set(src: str | isl.BasicSet, ctx: isl.Context | None = None) -> BasicSet:
obj = isl.BasicSet(src, ctx) if isinstance(src, str) else src

obj, name_to_dim = _strip_names(obj)
return BasicSet(obj, name_to_dim)
from .expression_like import (
Aff,
MultiAff,
PwAff,
PwMultiAff,
PwQPolynomial,
QPolynomial,
make_aff,
make_multi_aff,
make_pw_aff,
make_pw_multi_aff,
make_pw_qpolynomial,
make_qpolynomial,
)
from .set_like import (
BasicMap,
BasicSet,
Map,
Set,
make_basic_map,
make_basic_set,
make_map,
make_map_from_domain_and_range,
make_set,
)


__all__ = [
"Aff",
"BasicMap",
"BasicSet",
"Map",
"MultiAff",
"PwAff",
"PwMultiAff",
"PwQPolynomial",
"QPolynomial",
"Set",
"make_aff",
"make_basic_map",
"make_basic_set",
"make_map",
"make_map_from_domain_and_range",
"make_multi_aff",
"make_pw_aff",
"make_pw_multi_aff",
"make_pw_qpolynomial",
"make_qpolynomial",
"make_set",
]
Loading
Loading