Skip to content

Commit da5cfaf

Browse files
alexfiklinducer
authored andcommitted
port mappers away from deprecated CachingMapperMixin
1 parent 853eeac commit da5cfaf

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

pymbolic/geometric_algebra/mapper.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
Collector as CollectorBase,
3232
IdentityMapper as IdentityMapperBase,
3333
WalkMapper as WalkMapperBase,
34-
CachingMapperMixin
34+
CachedMapper,
3535
)
3636
from pymbolic.mapper.constant_folder import (
3737
ConstantFoldingMapper as ConstantFoldingMapperBase)
@@ -170,7 +170,11 @@ def map_derivative_source(self, expr):
170170

171171
# {{{ derivative binder
172172

173-
class DerivativeSourceAndNablaComponentCollector(CachingMapperMixin, Collector):
173+
class DerivativeSourceAndNablaComponentCollector(CachedMapper, Collector):
174+
def __init__(self) -> None:
175+
Collector.__init__(self)
176+
CachedMapper.__init__(self)
177+
174178
def map_nabla(self, expr):
175179
raise RuntimeError("DerivativeOccurrenceMapper must be invoked after "
176180
"Dimensionalizer--Nabla found, not allowed")

pymbolic/mapper/flop_counter.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
THE SOFTWARE.
2121
"""
2222

23-
from pymbolic.mapper import CombineMapper, CachingMapperMixin
23+
from pymbolic.mapper import CombineMapper, CachedMapper
2424

2525

2626
class FlopCounterBase(CombineMapper):
@@ -55,9 +55,10 @@ def map_if_positive(self, expr):
5555
self.rec(expr.else_))
5656

5757

58-
class FlopCounter(FlopCounterBase, CachingMapperMixin):
59-
def map_common_subexpression_uncached(self, expr):
60-
return self.rec(expr.child)
58+
class FlopCounter(CachedMapper, FlopCounterBase):
59+
def __init__(self) -> None:
60+
FlopCounterBase.__init__(self)
61+
CachedMapper.__init__(self)
6162

6263

6364
class CSEAwareFlopCounter(FlopCounterBase):
@@ -70,6 +71,7 @@ class CSEAwareFlopCounter(FlopCounterBase):
7071
reuse may take place.
7172
"""
7273
def __init__(self):
74+
super().__init__()
7375
self.cse_seen_set = set()
7476

7577
def map_common_subexpression(self, expr):

0 commit comments

Comments
 (0)