From e4766ca5c16eb56862a0fd290a46d76d389e3b76 Mon Sep 17 00:00:00 2001 From: Markus Holzer <markus.holzer@fau.de> Date: Tue, 3 May 2022 13:58:17 +0200 Subject: [PATCH] Implemented sp.Indexed --- pystencils/cache.py | 6 ++++-- pystencils/typing/leaf_typing.py | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pystencils/cache.py b/pystencils/cache.py index e62f982d3..34db1d658 100644 --- a/pystencils/cache.py +++ b/pystencils/cache.py @@ -1,8 +1,10 @@ import os from collections.abc import Hashable -from functools import partial, wraps, lru_cache +from functools import partial, wraps from itertools import chain +from functools import lru_cache as memorycache + from joblib import Memory from appdirs import user_cache_dir @@ -23,7 +25,7 @@ def _wrapper(wrapped_func, cached_func, *args, **kwargs): def memorycache_if_hashable(maxsize=128, typed=False): def wrapper(func): - return partial(_wrapper, func, lru_cache(maxsize, typed)(func)) + return partial(_wrapper, func, memorycache(maxsize, typed)(func)) return wrapper diff --git a/pystencils/typing/leaf_typing.py b/pystencils/typing/leaf_typing.py index b8cefb450..b5af7e4b2 100644 --- a/pystencils/typing/leaf_typing.py +++ b/pystencils/typing/leaf_typing.py @@ -190,7 +190,8 @@ class TypeAdder: # # TODO can we ignore this and move it to general expr handling, i.e. removing Mul? (See todo in backend) # # args_types = [self.figure_out_type(arg) for arg in expr.args if arg not in (-1, 1)] elif isinstance(expr, sp.Indexed): - raise NotImplementedError('sp.Indexed') + typed_symbol = expr.base.label + return expr, typed_symbol.dtype elif isinstance(expr, ExprCondPair): expr_expr, expr_type = self.figure_out_type(expr.expr) condition, condition_type = self.figure_out_type(expr.cond) -- GitLab