6767SetOrMap : TypeAlias = _isl .BasicSet | _isl .Set | _isl .BasicMap | _isl .Map
6868SetOrMapT = TypeVar ("SetOrMapT" , _isl .BasicSet , _isl .Set , _isl .BasicMap , _isl .Map )
6969
70- HasSpace : TypeAlias = (
70+ HasDimNames : TypeAlias = (
7171 _isl .Space
7272 | _isl .Constraint
7373 | _isl .LocalSpace
8181 | _isl .Map
8282 )
8383
84+ HasSpace : TypeAlias = (
85+ HasDimNames
86+ | _isl .QPolynomial
87+ | _isl .PwQPolynomial
88+ )
89+
8490
8591class IslObject (Protocol ):
8692 def get_ctx (self ) -> _isl .Context :
@@ -608,7 +614,7 @@ def obj_get_var_dict(
608614
609615
610616def obj_get_var_ids (
611- self : HasSpace ,
617+ self : HasDimNames ,
612618 dimtype : _isl .dim_type
613619 ) -> Sequence [str | None ]:
614620 """Return a list of :class:`Id` instances for :class:`dim_type` *dimtype*."""
@@ -619,7 +625,7 @@ def obj_get_var_ids(
619625
620626@_memoize_on_first_arg
621627def obj_get_var_names_not_none (
622- self : HasSpace ,
628+ self : HasDimNames ,
623629 dimtype : _isl .dim_type ,
624630 ) -> Sequence [str ]:
625631 """Return a list of dim names (in order) for :class:`dim_type` *dimtype*.
@@ -639,7 +645,7 @@ def obj_get_var_names_not_none(
639645
640646@_memoize_on_first_arg
641647def obj_get_var_names (
642- self : HasSpace ,
648+ self : HasDimNames ,
643649 dimtype : _isl .dim_type ,
644650 ) -> Sequence [str | None ]:
645651 """Return a list of dim names (in order) for :class:`dim_type` *dimtype*.
@@ -648,6 +654,39 @@ def obj_get_var_names(
648654 for i in range (self .dim (dimtype ))]
649655
650656
657+ @_memoize_on_first_arg
658+ def obj_get_var_names_not_none_via_space (
659+ self : HasSpace ,
660+ dimtype : _isl .dim_type ,
661+ ) -> Sequence [str ]:
662+ """Return a list of dim names (in order) for :class:`dim_type` *dimtype*.
663+
664+ Raise :exc:`ValueError` if any of the names is *None*.
665+
666+ .. versionadded:: 2025.2.5
667+ """
668+ space = self .get_space ()
669+ ndim = space .dim (dimtype )
670+ res = [n
671+ for i in range (ndim )
672+ if (n := space .get_dim_name (dimtype , i )) is not None ]
673+ if len (res ) != ndim :
674+ raise ValueError ("None encountered in dim names" )
675+ return res
676+
677+
678+ @_memoize_on_first_arg
679+ def obj_get_var_names_via_space (
680+ self : HasSpace ,
681+ dimtype : _isl .dim_type ,
682+ ) -> Sequence [str | None ]:
683+ """Return a list of dim names (in order) for :class:`dim_type` *dimtype*.
684+ """
685+ space = self .get_space ()
686+ return [space .get_dim_name (dimtype , i )
687+ for i in range (space .dim (dimtype ))]
688+
689+
651690def pwaff_get_pieces (self : _isl .PwAff | _isl .Aff ) -> list [tuple [_isl .Set , _isl .Aff ]]:
652691 if isinstance (self , _isl .Aff ):
653692 self = self .to_pw_aff ()
@@ -1058,12 +1097,18 @@ def _add_functionality() -> None:
10581097# {{{ common functionality
10591098
10601099for cls in ALL_CLASSES :
1061- if hasattr (cls , "get_space" ) and cls is not _isl . Space :
1100+ if hasattr (cls , "get_space" ):
10621101 cls .get_id_dict = obj_get_id_dict
10631102 cls .get_var_dict = obj_get_var_dict
10641103 cls .get_var_ids = obj_get_var_ids
1104+
1105+ # NB: This will include 'Space'
1106+ if hasattr (cls , "dim" ) and hasattr (cls , "get_dim_name" ):
10651107 cls .get_var_names = obj_get_var_names
10661108 cls .get_var_names_not_none = obj_get_var_names_not_none
1109+ elif hasattr (cls , "get_space" ):
1110+ cls .get_var_names = obj_get_var_names_via_space
1111+ cls .get_var_names_not_none = obj_get_var_names_not_none_via_space
10671112
10681113 # }}}
10691114
0 commit comments