islpy 2025.2.2__cp311-cp311-macosx_11_0_arm64.whl → 2025.2.5__cp311-cp311-macosx_11_0_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
islpy/__init__.py CHANGED
@@ -135,6 +135,7 @@ Alignable: TypeAlias = (
135
135
  | Aff | PwAff
136
136
  )
137
137
  AlignableT = TypeVar("AlignableT", bound=Alignable)
138
+ AlignableT2 = TypeVar("AlignableT2", bound=Alignable)
138
139
 
139
140
  # }}}
140
141
 
@@ -151,11 +152,21 @@ def _get_default_context() -> Context:
151
152
 
152
153
  def _set_dim_id(obj: AlignableT, dt: dim_type, idx: int, id: Id) -> AlignableT:
153
154
  if isinstance(obj, BasicSet):
154
- p, = obj.to_set().set_dim_id(dt, idx, id).get_basic_sets()
155
- return cast("AlignableT", p)
155
+ s = obj.to_set().set_dim_id(dt, idx, id)
156
+ basicsets = s.get_basic_sets()
157
+ if not basicsets:
158
+ result = BasicSet.empty(s.space)
159
+ else:
160
+ result, = basicsets
161
+ return cast("AlignableT", result)
156
162
  elif isinstance(obj, BasicMap):
157
- p, = obj.to_map().set_dim_id(dt, idx, id).get_basic_maps()
158
- return cast("AlignableT", p)
163
+ m = obj.to_map().set_dim_id(dt, idx, id)
164
+ basicmaps = m.get_basic_maps()
165
+ if not basicmaps:
166
+ result = BasicMap.empty(m.space)
167
+ else:
168
+ result, = basicmaps
169
+ return cast("AlignableT", result)
159
170
 
160
171
  return cast("AlignableT", obj.set_dim_id(dt, idx, id))
161
172
 
@@ -304,8 +315,8 @@ def align_spaces(
304
315
 
305
316
  def align_two(
306
317
  obj1: AlignableT,
307
- obj2: AlignableT,
308
- ) -> tuple[AlignableT, AlignableT]:
318
+ obj2: AlignableT2,
319
+ ) -> tuple[AlignableT, AlignableT2]:
309
320
  """Align the spaces of two objects, potentially modifying both of them.
310
321
 
311
322
  See also :func:`align_spaces`.
islpy/_isl.pyi CHANGED
@@ -1976,6 +1976,8 @@ class MultiVal:
1976
1976
 
1977
1977
  get_var_names = islpy._monkeypatch.obj_get_var_names
1978
1978
 
1979
+ get_var_names_not_none = islpy._monkeypatch.obj_get_var_names_not_none
1980
+
1979
1981
  __reduce__ = islpy._monkeypatch.generic_reduce
1980
1982
 
1981
1983
  __str__ = islpy._monkeypatch.generic_str
@@ -2558,6 +2560,8 @@ class Aff:
2558
2560
 
2559
2561
  get_var_names = islpy._monkeypatch.obj_get_var_names
2560
2562
 
2563
+ get_var_names_not_none = islpy._monkeypatch.obj_get_var_names_not_none
2564
+
2561
2565
  __reduce__ = islpy._monkeypatch.generic_reduce
2562
2566
 
2563
2567
  __str__ = islpy._monkeypatch.generic_str
@@ -2900,6 +2904,8 @@ class PwAff:
2900
2904
 
2901
2905
  get_var_names = islpy._monkeypatch.obj_get_var_names
2902
2906
 
2907
+ get_var_names_not_none = islpy._monkeypatch.obj_get_var_names_not_none
2908
+
2903
2909
  __reduce__ = islpy._monkeypatch.generic_reduce
2904
2910
 
2905
2911
  __str__ = islpy._monkeypatch.generic_str
@@ -3048,6 +3054,8 @@ class UnionPwAff:
3048
3054
 
3049
3055
  get_var_names = islpy._monkeypatch.obj_get_var_names
3050
3056
 
3057
+ get_var_names_not_none = islpy._monkeypatch.obj_get_var_names_not_none
3058
+
3051
3059
  __reduce__ = islpy._monkeypatch.generic_reduce
3052
3060
 
3053
3061
  __str__ = islpy._monkeypatch.generic_str
@@ -3122,6 +3130,8 @@ class MultiId:
3122
3130
 
3123
3131
  get_var_names = islpy._monkeypatch.obj_get_var_names
3124
3132
 
3133
+ get_var_names_not_none = islpy._monkeypatch.obj_get_var_names_not_none
3134
+
3125
3135
  __reduce__ = islpy._monkeypatch.generic_reduce
3126
3136
 
3127
3137
  __str__ = islpy._monkeypatch.generic_str
@@ -3506,6 +3516,8 @@ class MultiAff:
3506
3516
 
3507
3517
  get_var_names = islpy._monkeypatch.obj_get_var_names
3508
3518
 
3519
+ get_var_names_not_none = islpy._monkeypatch.obj_get_var_names_not_none
3520
+
3509
3521
  __reduce__ = islpy._monkeypatch.generic_reduce
3510
3522
 
3511
3523
  __str__ = islpy._monkeypatch.generic_str
@@ -3826,6 +3838,8 @@ class PwMultiAff:
3826
3838
 
3827
3839
  get_var_names = islpy._monkeypatch.obj_get_var_names
3828
3840
 
3841
+ get_var_names_not_none = islpy._monkeypatch.obj_get_var_names_not_none
3842
+
3829
3843
  __reduce__ = islpy._monkeypatch.generic_reduce
3830
3844
 
3831
3845
  __str__ = islpy._monkeypatch.generic_str
@@ -3999,6 +4013,8 @@ class UnionPwMultiAff:
3999
4013
 
4000
4014
  get_var_names = islpy._monkeypatch.obj_get_var_names
4001
4015
 
4016
+ get_var_names_not_none = islpy._monkeypatch.obj_get_var_names_not_none
4017
+
4002
4018
  __reduce__ = islpy._monkeypatch.generic_reduce
4003
4019
 
4004
4020
  __str__ = islpy._monkeypatch.generic_str
@@ -4238,6 +4254,8 @@ class MultiPwAff:
4238
4254
 
4239
4255
  get_var_names = islpy._monkeypatch.obj_get_var_names
4240
4256
 
4257
+ get_var_names_not_none = islpy._monkeypatch.obj_get_var_names_not_none
4258
+
4241
4259
  __reduce__ = islpy._monkeypatch.generic_reduce
4242
4260
 
4243
4261
  __str__ = islpy._monkeypatch.generic_str
@@ -4429,6 +4447,8 @@ class MultiUnionPwAff:
4429
4447
 
4430
4448
  get_var_names = islpy._monkeypatch.obj_get_var_names
4431
4449
 
4450
+ get_var_names_not_none = islpy._monkeypatch.obj_get_var_names_not_none
4451
+
4432
4452
  __reduce__ = islpy._monkeypatch.generic_reduce
4433
4453
 
4434
4454
  __str__ = islpy._monkeypatch.generic_str
@@ -4557,6 +4577,8 @@ class Constraint:
4557
4577
 
4558
4578
  get_var_names = islpy._monkeypatch.obj_get_var_names
4559
4579
 
4580
+ get_var_names_not_none = islpy._monkeypatch.obj_get_var_names_not_none
4581
+
4560
4582
  __str__ = islpy._monkeypatch.generic_str
4561
4583
 
4562
4584
  __repr__ = islpy._monkeypatch.generic_repr
@@ -4926,6 +4948,8 @@ class LocalSpace:
4926
4948
 
4927
4949
  get_var_names = islpy._monkeypatch.obj_get_var_names
4928
4950
 
4951
+ get_var_names_not_none = islpy._monkeypatch.obj_get_var_names_not_none
4952
+
4929
4953
  __str__ = islpy._monkeypatch.generic_str
4930
4954
 
4931
4955
  __repr__ = islpy._monkeypatch.generic_repr
@@ -5461,13 +5485,13 @@ class BasicSet:
5461
5485
 
5462
5486
  __ne__ = islpy._monkeypatch.obj_ne
5463
5487
 
5464
- __lt__ = islpy._monkeypatch.obj_lt
5488
+ __lt__ = islpy._monkeypatch.set_lt
5465
5489
 
5466
- __le__ = islpy._monkeypatch.obj_le
5490
+ __le__ = islpy._monkeypatch.set_le
5467
5491
 
5468
- __gt__ = islpy._monkeypatch.obj_gt
5492
+ __gt__ = islpy._monkeypatch.set_gt
5469
5493
 
5470
- __ge__ = islpy._monkeypatch.obj_ge
5494
+ __ge__ = islpy._monkeypatch.set_ge
5471
5495
 
5472
5496
  project_out_except = islpy._monkeypatch.obj_project_out_except
5473
5497
 
@@ -5483,21 +5507,23 @@ class BasicSet:
5483
5507
 
5484
5508
  get_var_names = islpy._monkeypatch.obj_get_var_names
5485
5509
 
5510
+ get_var_names_not_none = islpy._monkeypatch.obj_get_var_names_not_none
5511
+
5486
5512
  __reduce__ = islpy._monkeypatch.generic_reduce
5487
5513
 
5488
5514
  __str__ = islpy._monkeypatch.generic_str
5489
5515
 
5490
5516
  __repr__ = islpy._monkeypatch.generic_repr
5491
5517
 
5492
- __or__ = islpy._monkeypatch.obj_or
5518
+ __and__ = islpy._monkeypatch.bset_and
5493
5519
 
5494
- __ror__ = islpy._monkeypatch.obj_or
5520
+ __rand__ = islpy._monkeypatch.bset_and
5495
5521
 
5496
- __and__ = islpy._monkeypatch.obj_and
5522
+ __or__ = islpy._monkeypatch.set_or
5497
5523
 
5498
- __rand__ = islpy._monkeypatch.obj_and
5524
+ __ror__ = islpy._monkeypatch.set_or
5499
5525
 
5500
- __sub__ = islpy._monkeypatch.obj_sub
5526
+ __sub__ = islpy._monkeypatch.set_sub
5501
5527
 
5502
5528
  get_constraints = islpy._monkeypatch.basic_obj_get_constraints
5503
5529
 
@@ -6222,13 +6248,13 @@ class BasicMap:
6222
6248
 
6223
6249
  __ne__ = islpy._monkeypatch.obj_ne
6224
6250
 
6225
- __lt__ = islpy._monkeypatch.obj_lt
6251
+ __lt__ = islpy._monkeypatch.map_lt
6226
6252
 
6227
- __le__ = islpy._monkeypatch.obj_le
6253
+ __le__ = islpy._monkeypatch.map_le
6228
6254
 
6229
- __gt__ = islpy._monkeypatch.obj_gt
6255
+ __gt__ = islpy._monkeypatch.map_gt
6230
6256
 
6231
- __ge__ = islpy._monkeypatch.obj_ge
6257
+ __ge__ = islpy._monkeypatch.map_ge
6232
6258
 
6233
6259
  project_out_except = islpy._monkeypatch.obj_project_out_except
6234
6260
 
@@ -6242,21 +6268,23 @@ class BasicMap:
6242
6268
 
6243
6269
  get_var_names = islpy._monkeypatch.obj_get_var_names
6244
6270
 
6271
+ get_var_names_not_none = islpy._monkeypatch.obj_get_var_names_not_none
6272
+
6245
6273
  __reduce__ = islpy._monkeypatch.generic_reduce
6246
6274
 
6247
6275
  __str__ = islpy._monkeypatch.generic_str
6248
6276
 
6249
6277
  __repr__ = islpy._monkeypatch.generic_repr
6250
6278
 
6251
- __or__ = islpy._monkeypatch.obj_or
6279
+ __and__ = islpy._monkeypatch.bmap_and
6252
6280
 
6253
- __ror__ = islpy._monkeypatch.obj_or
6281
+ __rand__ = islpy._monkeypatch.bmap_and
6254
6282
 
6255
- __and__ = islpy._monkeypatch.obj_and
6283
+ __or__ = islpy._monkeypatch.map_or
6256
6284
 
6257
- __rand__ = islpy._monkeypatch.obj_and
6285
+ __ror__ = islpy._monkeypatch.map_or
6258
6286
 
6259
- __sub__ = islpy._monkeypatch.obj_sub
6287
+ __sub__ = islpy._monkeypatch.map_sub
6260
6288
 
6261
6289
  get_constraints = islpy._monkeypatch.basic_obj_get_constraints
6262
6290
 
@@ -6726,13 +6754,13 @@ class Set:
6726
6754
 
6727
6755
  __ne__ = islpy._monkeypatch.obj_ne
6728
6756
 
6729
- __lt__ = islpy._monkeypatch.obj_lt
6757
+ __lt__ = islpy._monkeypatch.set_lt
6730
6758
 
6731
- __le__ = islpy._monkeypatch.obj_le
6759
+ __le__ = islpy._monkeypatch.set_le
6732
6760
 
6733
- __gt__ = islpy._monkeypatch.obj_gt
6761
+ __gt__ = islpy._monkeypatch.set_gt
6734
6762
 
6735
- __ge__ = islpy._monkeypatch.obj_ge
6763
+ __ge__ = islpy._monkeypatch.set_ge
6736
6764
 
6737
6765
  project_out_except = islpy._monkeypatch.obj_project_out_except
6738
6766
 
@@ -6748,21 +6776,23 @@ class Set:
6748
6776
 
6749
6777
  get_var_names = islpy._monkeypatch.obj_get_var_names
6750
6778
 
6779
+ get_var_names_not_none = islpy._monkeypatch.obj_get_var_names_not_none
6780
+
6751
6781
  __reduce__ = islpy._monkeypatch.generic_reduce
6752
6782
 
6753
6783
  __str__ = islpy._monkeypatch.generic_str
6754
6784
 
6755
6785
  __repr__ = islpy._monkeypatch.generic_repr
6756
6786
 
6757
- __or__ = islpy._monkeypatch.obj_or
6787
+ __and__ = islpy._monkeypatch.set_and
6758
6788
 
6759
- __ror__ = islpy._monkeypatch.obj_or
6789
+ __rand__ = islpy._monkeypatch.set_and
6760
6790
 
6761
- __and__ = islpy._monkeypatch.obj_and
6791
+ __or__ = islpy._monkeypatch.set_or
6762
6792
 
6763
- __rand__ = islpy._monkeypatch.obj_and
6793
+ __ror__ = islpy._monkeypatch.set_or
6764
6794
 
6765
- __sub__ = islpy._monkeypatch.obj_sub
6795
+ __sub__ = islpy._monkeypatch.set_sub
6766
6796
 
6767
6797
  get_basic_sets = islpy._monkeypatch.set_get_basic_sets
6768
6798
 
@@ -7405,13 +7435,13 @@ class Map:
7405
7435
 
7406
7436
  __ne__ = islpy._monkeypatch.obj_ne
7407
7437
 
7408
- __lt__ = islpy._monkeypatch.obj_lt
7438
+ __lt__ = islpy._monkeypatch.map_lt
7409
7439
 
7410
- __le__ = islpy._monkeypatch.obj_le
7440
+ __le__ = islpy._monkeypatch.map_le
7411
7441
 
7412
- __gt__ = islpy._monkeypatch.obj_gt
7442
+ __gt__ = islpy._monkeypatch.map_gt
7413
7443
 
7414
- __ge__ = islpy._monkeypatch.obj_ge
7444
+ __ge__ = islpy._monkeypatch.map_ge
7415
7445
 
7416
7446
  project_out_except = islpy._monkeypatch.obj_project_out_except
7417
7447
 
@@ -7425,21 +7455,23 @@ class Map:
7425
7455
 
7426
7456
  get_var_names = islpy._monkeypatch.obj_get_var_names
7427
7457
 
7458
+ get_var_names_not_none = islpy._monkeypatch.obj_get_var_names_not_none
7459
+
7428
7460
  __reduce__ = islpy._monkeypatch.generic_reduce
7429
7461
 
7430
7462
  __str__ = islpy._monkeypatch.generic_str
7431
7463
 
7432
7464
  __repr__ = islpy._monkeypatch.generic_repr
7433
7465
 
7434
- __or__ = islpy._monkeypatch.obj_or
7466
+ __and__ = islpy._monkeypatch.map_and
7435
7467
 
7436
- __ror__ = islpy._monkeypatch.obj_or
7468
+ __rand__ = islpy._monkeypatch.map_and
7437
7469
 
7438
- __and__ = islpy._monkeypatch.obj_and
7470
+ __or__ = islpy._monkeypatch.map_or
7439
7471
 
7440
- __rand__ = islpy._monkeypatch.obj_and
7472
+ __ror__ = islpy._monkeypatch.map_or
7441
7473
 
7442
- __sub__ = islpy._monkeypatch.obj_sub
7474
+ __sub__ = islpy._monkeypatch.map_sub
7443
7475
 
7444
7476
  get_basic_maps = islpy._monkeypatch.map_get_basic_maps
7445
7477
 
@@ -7624,6 +7656,8 @@ class UnionSet:
7624
7656
 
7625
7657
  get_var_names = islpy._monkeypatch.obj_get_var_names
7626
7658
 
7659
+ get_var_names_not_none = islpy._monkeypatch.obj_get_var_names_not_none
7660
+
7627
7661
  __reduce__ = islpy._monkeypatch.generic_reduce
7628
7662
 
7629
7663
  __str__ = islpy._monkeypatch.generic_str
@@ -7940,6 +7974,8 @@ class UnionMap:
7940
7974
 
7941
7975
  get_var_names = islpy._monkeypatch.obj_get_var_names
7942
7976
 
7977
+ get_var_names_not_none = islpy._monkeypatch.obj_get_var_names_not_none
7978
+
7943
7979
  __reduce__ = islpy._monkeypatch.generic_reduce
7944
7980
 
7945
7981
  __str__ = islpy._monkeypatch.generic_str
@@ -7988,6 +8024,8 @@ class Point:
7988
8024
 
7989
8025
  get_var_names = islpy._monkeypatch.obj_get_var_names
7990
8026
 
8027
+ get_var_names_not_none = islpy._monkeypatch.obj_get_var_names_not_none
8028
+
7991
8029
  __str__ = islpy._monkeypatch.generic_str
7992
8030
 
7993
8031
  __repr__ = islpy._monkeypatch.generic_repr
@@ -8162,6 +8200,8 @@ class QPolynomial:
8162
8200
 
8163
8201
  get_var_names = islpy._monkeypatch.obj_get_var_names
8164
8202
 
8203
+ get_var_names_not_none = islpy._monkeypatch.obj_get_var_names_not_none
8204
+
8165
8205
  __str__ = islpy._monkeypatch.generic_str
8166
8206
 
8167
8207
  __repr__ = islpy._monkeypatch.generic_repr
@@ -8333,6 +8373,8 @@ class PwQPolynomial:
8333
8373
 
8334
8374
  get_var_names = islpy._monkeypatch.obj_get_var_names
8335
8375
 
8376
+ get_var_names_not_none = islpy._monkeypatch.obj_get_var_names_not_none
8377
+
8336
8378
  __reduce__ = islpy._monkeypatch.generic_reduce
8337
8379
 
8338
8380
  __str__ = islpy._monkeypatch.generic_str
@@ -8391,6 +8433,8 @@ class QPolynomialFold:
8391
8433
 
8392
8434
  get_var_names = islpy._monkeypatch.obj_get_var_names
8393
8435
 
8436
+ get_var_names_not_none = islpy._monkeypatch.obj_get_var_names_not_none
8437
+
8394
8438
  __str__ = islpy._monkeypatch.generic_str
8395
8439
 
8396
8440
  __repr__ = islpy._monkeypatch.generic_repr
@@ -8522,6 +8566,8 @@ class PwQPolynomialFold:
8522
8566
 
8523
8567
  get_var_names = islpy._monkeypatch.obj_get_var_names
8524
8568
 
8569
+ get_var_names_not_none = islpy._monkeypatch.obj_get_var_names_not_none
8570
+
8525
8571
  __reduce__ = islpy._monkeypatch.generic_reduce
8526
8572
 
8527
8573
  __str__ = islpy._monkeypatch.generic_str
@@ -8626,6 +8672,8 @@ class UnionPwQPolynomialFold:
8626
8672
 
8627
8673
  get_var_names = islpy._monkeypatch.obj_get_var_names
8628
8674
 
8675
+ get_var_names_not_none = islpy._monkeypatch.obj_get_var_names_not_none
8676
+
8629
8677
  __str__ = islpy._monkeypatch.generic_str
8630
8678
 
8631
8679
  __repr__ = islpy._monkeypatch.generic_repr
@@ -8743,6 +8791,8 @@ class UnionPwQPolynomial:
8743
8791
 
8744
8792
  get_var_names = islpy._monkeypatch.obj_get_var_names
8745
8793
 
8794
+ get_var_names_not_none = islpy._monkeypatch.obj_get_var_names_not_none
8795
+
8746
8796
  __reduce__ = islpy._monkeypatch.generic_reduce
8747
8797
 
8748
8798
  __str__ = islpy._monkeypatch.generic_str
islpy/_monkeypatch.py CHANGED
@@ -5,7 +5,6 @@ from functools import update_wrapper
5
5
  from sys import intern
6
6
  from typing import (
7
7
  TYPE_CHECKING,
8
- Any,
9
8
  ClassVar,
10
9
  Concatenate,
11
10
  Literal,
@@ -43,6 +42,10 @@ _CHECK_DIM_TYPES: tuple[_isl.dim_type, ...] = (
43
42
 
44
43
  # {{{ typing helpers
45
44
 
45
+ T = TypeVar("T")
46
+ P = ParamSpec("P")
47
+ ResultT = TypeVar("ResultT")
48
+
46
49
  SelfT = TypeVar("SelfT")
47
50
 
48
51
  BasicT = TypeVar("BasicT", _isl.BasicSet, _isl.BasicMap)
@@ -54,36 +57,28 @@ ExprLikeT = TypeVar("ExprLikeT", _isl.Aff, _isl.PwAff,
54
57
  _isl.QPolynomial, _isl.PwQPolynomial
55
58
  )
56
59
  SetLikeT = TypeVar("SetLikeT", bound=_isl.BasicSet | _isl.Set)
60
+
61
+ SetOrBasic: TypeAlias = _isl.BasicSet | _isl.Set
62
+ SetOrBasicT = TypeVar("SetOrBasicT", bound=SetOrBasic)
63
+
64
+ MapOrBasic: TypeAlias = _isl.BasicMap | _isl.Map
65
+ MapOrBasicT = TypeVar("MapOrBasicT", bound=MapOrBasic)
66
+
57
67
  SetOrMap: TypeAlias = _isl.BasicSet | _isl.Set | _isl.BasicMap | _isl.Map
58
- SetOrMapT = TypeVar("SetOrMapT", bound=SetOrMap)
68
+ SetOrMapT = TypeVar("SetOrMapT", _isl.BasicSet, _isl.Set, _isl.BasicMap, _isl.Map)
59
69
 
60
70
  HasSpace: TypeAlias = (
61
71
  _isl.Space
62
- | _isl.Aff
63
- | _isl.BasicMap
64
- | _isl.BasicSet
65
72
  | _isl.Constraint
66
73
  | _isl.LocalSpace
67
- | _isl.Map
74
+ | _isl.Aff
68
75
  | _isl.MultiAff
69
- | _isl.MultiId
70
- | _isl.MultiPwAff
71
- | _isl.MultiUnionPwAff
72
- | _isl.MultiVal
73
- | _isl.Point
74
76
  | _isl.PwAff
75
77
  | _isl.PwMultiAff
76
- | _isl.PwQPolynomial
77
- | _isl.PwQPolynomialFold
78
- | _isl.QPolynomial
79
- | _isl.QPolynomialFold
78
+ | _isl.BasicMap
79
+ | _isl.BasicSet
80
80
  | _isl.Set
81
- | _isl.UnionMap
82
- | _isl.UnionPwAff
83
- | _isl.UnionPwMultiAff
84
- | _isl.UnionPwQPolynomial
85
- | _isl.UnionPwQPolynomialFold
86
- | _isl.UnionSet
81
+ | _isl.Map
87
82
  )
88
83
 
89
84
 
@@ -101,34 +96,30 @@ class IslObject(Protocol):
101
96
 
102
97
  # {{{ copied verbatim from pytools to avoid numpy/pytools dependency
103
98
 
104
- F = TypeVar("F", bound=Callable[..., Any])
105
-
106
-
107
99
  class _HasKwargs:
108
100
  pass
109
101
 
110
102
 
111
- def _memoize_on_first_arg(function: F, cache_dict_name: str | None = None) -> F:
103
+ def _memoize_on_first_arg(
104
+ function: Callable[Concatenate[T, P], ResultT], *,
105
+ cache_dict_name: str | None = None) -> Callable[Concatenate[T, P], ResultT]:
112
106
  """Like :func:`memoize_method`, but for functions that take the object
113
107
  in which do memoization information is stored as first argument.
114
108
 
115
109
  Supports cache deletion via ``function_name.clear_cache(self)``.
116
110
  """
117
- from sys import intern
118
111
 
119
112
  if cache_dict_name is None:
120
113
  cache_dict_name = intern(
121
114
  f"_memoize_dic_{function.__module__}{function.__name__}"
122
115
  )
123
116
 
124
- def wrapper(obj, *args, **kwargs):
125
- if kwargs:
126
- key = (_HasKwargs, frozenset(kwargs.items()), *args)
127
- else:
128
- key = args
117
+ def wrapper(obj: T, *args: P.args, **kwargs: P.kwargs) -> ResultT:
118
+ key = (_HasKwargs, frozenset(kwargs.items()), *args) if kwargs else args
129
119
 
120
+ assert cache_dict_name is not None
130
121
  try:
131
- return getattr(obj, cache_dict_name)[key]
122
+ return cast("ResultT", getattr(obj, cache_dict_name)[key])
132
123
  except AttributeError:
133
124
  attribute_error = True
134
125
  except KeyError:
@@ -138,11 +129,10 @@ def _memoize_on_first_arg(function: F, cache_dict_name: str | None = None) -> F:
138
129
  if attribute_error:
139
130
  object.__setattr__(obj, cache_dict_name, {key: result})
140
131
  return result
141
- else:
142
- getattr(obj, cache_dict_name)[key] = result
143
- return result
132
+ getattr(obj, cache_dict_name)[key] = result
133
+ return result
144
134
 
145
- def clear_cache(obj):
135
+ def clear_cache(obj: object):
146
136
  object.__delattr__(obj, cache_dict_name)
147
137
 
148
138
  from functools import update_wrapper
@@ -152,7 +142,8 @@ def _memoize_on_first_arg(function: F, cache_dict_name: str | None = None) -> F:
152
142
  # into the function's dict is moderately sketchy.
153
143
  new_wrapper.clear_cache = clear_cache # type: ignore[attr-defined]
154
144
 
155
- return cast("F", new_wrapper)
145
+ return new_wrapper
146
+
156
147
 
157
148
  # }}}
158
149
 
@@ -190,7 +181,7 @@ def context_ne(self: object, other: object) -> bool:
190
181
  return not self.__eq__(other)
191
182
 
192
183
 
193
- def generic_reduce(self: IslObject):
184
+ def generic_reduce(self: HasSpace):
194
185
  ctx = self.get_ctx()
195
186
  prn = _isl.Printer.to_str(ctx)
196
187
  prn = getattr(prn, f"print_{self._base_name}")(self)
@@ -331,21 +322,100 @@ def space_create_from_names(
331
322
  return result
332
323
 
333
324
 
334
- def obj_or(self: SetOrMapT, other: object) -> SetOrMapT:
325
+ def set_or(
326
+ self: _isl.Set,
327
+ other: _isl.Set | _isl.BasicSet,
328
+ ) -> _isl.Set:
329
+ try:
330
+ return self.union(other)
331
+ except TypeError:
332
+ return NotImplemented
333
+
334
+
335
+ def bset_and(
336
+ self: _isl.BasicSet,
337
+ other: SetOrBasicT,
338
+ ) -> SetOrBasicT:
339
+ if isinstance(other, _isl.Set):
340
+ try:
341
+ return self.to_set().intersect(other)
342
+ except TypeError:
343
+ return NotImplemented
344
+ else:
345
+ try:
346
+ return self.intersect(other)
347
+ except TypeError:
348
+ return NotImplemented
349
+
350
+
351
+ def set_and(
352
+ self: _isl.Set,
353
+ other: _isl.Set | _isl.BasicSet,
354
+ ) -> _isl.Set:
355
+ if isinstance(self, _isl.BasicSet):
356
+ self = self.to_set()
357
+ try:
358
+ return self.intersect(other)
359
+ except TypeError:
360
+ return NotImplemented
361
+
362
+
363
+ def set_sub(
364
+ self: _isl.Set | _isl.BasicSet,
365
+ other: _isl.Set | _isl.BasicSet,
366
+ ) -> _isl.Set:
367
+ if isinstance(self, _isl.BasicSet):
368
+ self = self.to_set()
369
+ try:
370
+ return self.subtract(other)
371
+ except TypeError:
372
+ return NotImplemented
373
+
374
+
375
+ def map_or(
376
+ self: _isl.Map | _isl.BasicMap,
377
+ other: _isl.Map | _isl.BasicMap,
378
+ ) -> _isl.Map:
379
+ if isinstance(self, _isl.BasicMap):
380
+ self = self.to_map()
335
381
  try:
336
382
  return self.union(other)
337
383
  except TypeError:
338
384
  return NotImplemented
339
385
 
340
386
 
341
- def obj_and(self: SetOrMapT, other: object) -> SetOrMapT:
387
+ def bmap_and(
388
+ self: _isl.BasicMap,
389
+ other: MapOrBasicT,
390
+ ) -> MapOrBasicT:
391
+ if isinstance(other, _isl.Map):
392
+ try:
393
+ return self.to_map().intersect(other)
394
+ except TypeError:
395
+ return NotImplemented
396
+ else:
397
+ try:
398
+ return self.intersect(other)
399
+ except TypeError:
400
+ return NotImplemented
401
+
402
+
403
+ def map_and(
404
+ self: _isl.Map,
405
+ other: _isl.Map | _isl.BasicMap,
406
+ ) -> _isl.Map:
342
407
  try:
343
408
  return self.intersect(other)
344
409
  except TypeError:
345
410
  return NotImplemented
346
411
 
347
412
 
348
- def obj_sub(self: SetOrMapT, other: object) -> SetOrMapT:
413
+ def map_sub(
414
+ self: _isl.Map | _isl.BasicMap,
415
+ other: _isl.Map | _isl.BasicMap,
416
+ ) -> _isl.Map:
417
+ if isinstance(self, _isl.BasicMap):
418
+ self = self.to_map()
349
419
  try:
350
420
  return self.subtract(other)
351
421
  except TypeError:
@@ -538,16 +608,42 @@ def obj_get_var_dict(
538
608
  def obj_get_var_ids(
539
609
  self: HasSpace,
540
610
  dimtype: _isl.dim_type
541
- ) -> Sequence[str]:
611
+ ) -> Sequence[str | None]:
542
612
  """Return a list of :class:`Id` instances for :class:`dim_type` *dimtype*."""
543
- return [self.get_dim_name(dimtype, i) for i in range(self.dim(dimtype))]
613
+ return [
614
+ self.get_dim_name(dimtype, i)
615
+ for i in range(self.dim(dimtype))]
616
+
617
+
618
+ @_memoize_on_first_arg
619
+ def obj_get_var_names_not_none(
620
+ self: HasSpace,
621
+ dimtype: _isl.dim_type,
622
+ ) -> Sequence[str]:
623
+ """Return a list of dim names (in order) for :class:`dim_type` *dimtype*.
624
+
625
+ Raise :exc:`ValueError` if any of the names is *None*.
626
+
627
+ .. versionadded:: 2025.2.5
628
+ """
629
+ ndim = self.dim(dimtype)
630
+ res = [n
631
+ for i in range(ndim)
632
+ if (n := self.get_dim_name(dimtype, i)) is not None]
633
+ if len(res) != ndim:
634
+ raise ValueError("None encountered in dim names")
635
+ return res
544
636
 
545
637
 
546
638
  @_memoize_on_first_arg
547
- def obj_get_var_names(self: HasSpace, dimtype: _isl.dim_type) -> Sequence[str]:
548
- """Return a list of dim names (in order) for :class:`dim_type` *dimtype*."""
639
+ def obj_get_var_names(
640
+ self: HasSpace,
641
+ dimtype: _isl.dim_type,
642
+ ) -> Sequence[str | None]:
643
+ """Return a list of dim names (in order) for :class:`dim_type` *dimtype*.
644
+ """
549
645
  return [self.get_dim_name(dimtype, i)
550
- for i in range(self.dim(dimtype))]
646
+ for i in range(self.dim(dimtype))]
551
647
 
552
648
 
553
649
  def pwaff_get_pieces(self: _isl.PwAff | _isl.Aff) -> list[tuple[_isl.Set, _isl.Aff]]:
@@ -585,7 +681,7 @@ def pw_get_aggregate_domain(self: _isl.PwAff | _isl.PwQPolynomial) -> _isl.Set:
585
681
 
586
682
  result = _isl.Set.empty(self.get_domain_space())
587
683
  for dom, _ in self.get_pieces():
588
- result = result.union(cast("_isl.Set", dom))
684
+ result = result.union(dom)
589
685
 
590
686
  return result
591
687
 
@@ -657,7 +753,7 @@ def expr_like_add(self: ExprLikeT, other: ExprLikeT | int | _isl.Val) -> ExprLik
657
753
  return NotImplemented
658
754
 
659
755
 
660
- def expr_like_sub(self: ExprLikeT, other: ExprLikeT | int | _isl.Val):
756
+ def expr_like_sub(self: ExprLikeT, other: ExprLikeT | int | _isl.Val) -> ExprLikeT:
661
757
  if not isinstance(other, ExprLike):
662
758
  other = _number_to_expr_like(self, other)
663
759
 
@@ -727,29 +823,45 @@ for cls in ALL_CLASSES:
727
823
  cls.__ne__ = obj_ne
728
824
 
729
825
 
730
- def obj_lt(self: SetOrMapT, other: SetOrMapT) -> bool:
826
+ def set_lt(self: _isl.BasicSet | _isl.Set, other: _isl.BasicSet | _isl.Set) -> bool:
731
827
  return self.is_strict_subset(other)
732
828
 
733
829
 
734
- def obj_le(self: SetOrMapT, other: SetOrMapT) -> bool:
830
+ def set_le(self: _isl.BasicSet | _isl.Set, other: _isl.BasicSet | _isl.Set) -> bool:
735
831
  return self.is_subset(other)
736
832
 
737
833
 
738
- def obj_gt(self: SetOrMapT, other: SetOrMapT) -> bool:
834
+ def set_gt(self: _isl.BasicSet | _isl.Set, other: _isl.BasicSet | _isl.Set) -> bool:
739
835
  return other.is_strict_subset(self)
740
836
 
741
837
 
742
- def obj_ge(self: SetOrMapT, other: SetOrMapT) -> bool:
838
+ def set_ge(self: _isl.BasicSet | _isl.Set, other: _isl.BasicSet | _isl.Set) -> bool:
839
+ return other.is_subset(self)
840
+
841
+
842
+ def map_lt(self: _isl.BasicMap | _isl.Map, other: _isl.BasicMap | _isl.Map) -> bool:
843
+ return self.is_strict_subset(other)
844
+
845
+
846
+ def map_le(self: _isl.BasicMap | _isl.Map, other: _isl.BasicMap | _isl.Map) -> bool:
847
+ return self.is_subset(other)
848
+
849
+
850
+ def map_gt(self: _isl.BasicMap | _isl.Map, other: _isl.BasicMap | _isl.Map) -> bool:
851
+ return other.is_strict_subset(self)
852
+
853
+
854
+ def map_ge(self: _isl.BasicMap | _isl.Map, other: _isl.BasicMap | _isl.Map) -> bool:
743
855
  return other.is_subset(self)
744
856
 
745
857
 
746
858
  # {{{ project_out_except
747
859
 
748
860
  def obj_project_out_except(
749
- obj: SetLikeT,
861
+ obj: SetOrMapT,
750
862
  names: Collection[str],
751
863
  types: Collection[_isl.dim_type]
752
- ) -> SetLikeT:
864
+ ) -> SetOrMapT:
753
865
  """
754
866
  :param types: list of :class:`dim_type` determining
755
867
  the types of axes to project out
@@ -786,10 +898,10 @@ def obj_project_out_except(
786
898
  # {{{ eliminate_except
787
899
 
788
900
  def obj_eliminate_except(
789
- obj: SetLikeT,
901
+ obj: SetOrMapT,
790
902
  names: Collection[str],
791
903
  types: Collection[_isl.dim_type]
792
- ) -> SetLikeT:
904
+ ) -> SetOrMapT:
793
905
  """
794
906
  :param types: list of :class:`dim_type` determining
795
907
  the types of axes to eliminate
@@ -871,12 +983,23 @@ def _add_functionality() -> None:
871
983
 
872
984
  # {{{ Python set-like behavior
873
985
 
874
- for cls in [_isl.BasicSet, _isl.BasicMap, _isl.Set, _isl.Map]:
875
- cls.__or__ = obj_or
876
- cls.__ror__ = obj_or
877
- cls.__and__ = obj_and
878
- cls.__rand__ = obj_and
879
- cls.__sub__ = obj_sub
986
+ _isl.BasicSet.__and__ = bset_and
987
+ _isl.BasicSet.__rand__ = bset_and
988
+ _isl.Set.__and__ = set_and
989
+ _isl.Set.__rand__ = set_and
990
+ for cls in [_isl.BasicSet, _isl.Set]:
991
+ cls.__or__ = set_or
992
+ cls.__ror__ = set_or
993
+ cls.__sub__ = set_sub
994
+
995
+ _isl.BasicMap.__and__ = bmap_and
996
+ _isl.BasicMap.__rand__ = bmap_and
997
+ _isl.Map.__and__ = map_and
998
+ _isl.Map.__rand__ = map_and
999
+ for cls in [_isl.BasicMap, _isl.Map]:
1000
+ cls.__or__ = map_or
1001
+ cls.__ror__ = map_or
1002
+ cls.__sub__ = map_sub
880
1003
 
881
1004
  # }}}
882
1005
 
@@ -938,6 +1061,7 @@ for cls in ALL_CLASSES:
938
1061
  cls.get_var_dict = obj_get_var_dict
939
1062
  cls.get_var_ids = obj_get_var_ids
940
1063
  cls.get_var_names = obj_get_var_names
1064
+ cls.get_var_names_not_none = obj_get_var_names_not_none
941
1065
 
942
1066
  # }}}
943
1067
 
@@ -1005,11 +1129,17 @@ for cls in ALL_CLASSES:
1005
1129
 
1006
1130
  # {{{ rich comparisons
1007
1131
 
1008
- for cls in [_isl.BasicSet, _isl.BasicMap, _isl.Set, _isl.Map]:
1009
- cls.__lt__ = obj_lt
1010
- cls.__le__ = obj_le
1011
- cls.__gt__ = obj_gt
1012
- cls.__ge__ = obj_ge
1132
+ for cls in [_isl.BasicSet, _isl.Set]:
1133
+ cls.__lt__ = set_lt
1134
+ cls.__le__ = set_le
1135
+ cls.__gt__ = set_gt
1136
+ cls.__ge__ = set_ge
1137
+
1138
+ for cls in [_isl.BasicMap, _isl.Map]:
1139
+ cls.__lt__ = map_lt
1140
+ cls.__le__ = map_le
1141
+ cls.__gt__ = map_gt
1142
+ cls.__ge__ = map_ge
1013
1143
 
1014
1144
  # }}}
1015
1145
 
@@ -1024,10 +1154,6 @@ for cls in ALL_CLASSES:
1024
1154
  _add_functionality()
1025
1155
 
1026
1156
 
1027
- P = ParamSpec("P")
1028
- ResultT = TypeVar("ResultT")
1029
-
1030
-
1031
1157
  _DOWNCAST_RE = re.compile(
1032
1158
  r"Downcast from :class:`([A-Za-z]+)` to :class:`([A-Za-z]+)`.")
1033
1159
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: islpy
3
- Version: 2025.2.2
3
+ Version: 2025.2.5
4
4
  Summary: Wrapper around isl, an integer set library
5
5
  Author-Email: Andreas Kloeckner <inform@tiker.net>
6
6
  License-Expression: MIT
@@ -0,0 +1,9 @@
1
+ islpy/version.py,sha256=9KVEg7OX9uCaA6ElUMeiAh-zDrxsy3u2H6VQm_-LTUE,301
2
+ islpy/__init__.py,sha256=0AdPhWQMf1DUB5DDisLP39rN0djxueftEWqfX4_R5Hk,13363
3
+ islpy/_isl.pyi,sha256=c9l3pXn3DEtGO0WscxXu6RsfK1WseF0hdE7oFncXUnA,262025
4
+ islpy/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ islpy/_isl.cpython-311-darwin.so,sha256=iI6GktRqAvFJUPu5v3kMLW_sEdqLFMmdCzXpNQSEE4I,7910776
6
+ islpy/_monkeypatch.py,sha256=3ji2nD8gYxY59qwjJiasmeKOI0oSbrxEiXbswjmJXoU,34881
7
+ islpy-2025.2.5.dist-info/RECORD,,
8
+ islpy-2025.2.5.dist-info/WHEEL,sha256=7CikrUOKtiy-2ivl-sZ5UBq05y8ywDmf9_HO2E_GAYY,141
9
+ islpy-2025.2.5.dist-info/METADATA,sha256=dFfe1_neHbSBhU6nwxnsMoO3bNIt1zonZaKdTbVDIbw,2966
@@ -1,9 +0,0 @@
1
- islpy/version.py,sha256=9KVEg7OX9uCaA6ElUMeiAh-zDrxsy3u2H6VQm_-LTUE,301
2
- islpy/__init__.py,sha256=di9XuiCE0E17rYvJF2odx710bD4X07gsKGWDW6oSgH0,13021
3
- islpy/_isl.pyi,sha256=_QvIK3y21H8sud47dr3bBOfxkSONwZzxV1x09WIxtRQ,260121
4
- islpy/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- islpy/_isl.cpython-311-darwin.so,sha256=iI6GktRqAvFJUPu5v3kMLW_sEdqLFMmdCzXpNQSEE4I,7910776
6
- islpy/_monkeypatch.py,sha256=J_EIwyHBinfCo_rBu1V9o1OzG9R3dE34lJ0XIMOJSQ4,31309
7
- islpy-2025.2.2.dist-info/RECORD,,
8
- islpy-2025.2.2.dist-info/WHEEL,sha256=7CikrUOKtiy-2ivl-sZ5UBq05y8ywDmf9_HO2E_GAYY,141
9
- islpy-2025.2.2.dist-info/METADATA,sha256=Us2hmRlX7V2rNYGp3pg3ZEqYgbSbuzNYT7IIHd9dbT4,2966