From 72531dc1f998f86b5cb442a0b35bea17f2281067 Mon Sep 17 00:00:00 2001 From: Frederik Hennig <frederik.hennig@fau.de> Date: Mon, 21 Oct 2024 08:44:32 +0200 Subject: [PATCH] fix typifier documentation, rename `items_matrix` to `items_grid`. --- src/pystencils/backend/ast/expressions.py | 2 +- src/pystencils/backend/emission.py | 2 +- src/pystencils/backend/kernelcreation/freeze.py | 2 +- src/pystencils/backend/kernelcreation/typification.py | 10 ++-------- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/pystencils/backend/ast/expressions.py b/src/pystencils/backend/ast/expressions.py index 51807d96a..151f86c6e 100644 --- a/src/pystencils/backend/ast/expressions.py +++ b/src/pystencils/backend/ast/expressions.py @@ -818,7 +818,7 @@ class PsArrayInitList(PsExpression): self._items = np.array(items, dtype=np.object_) @property - def items_matrix(self) -> NDArray[np.object_]: + def items_grid(self) -> NDArray[np.object_]: return self._items @property diff --git a/src/pystencils/backend/emission.py b/src/pystencils/backend/emission.py index c7969fa50..579d47648 100644 --- a/src/pystencils/backend/emission.py +++ b/src/pystencils/backend/emission.py @@ -377,7 +377,7 @@ class CAstPrinter: return "{ " + entries + " }" pc.push_op(Ops.Weakest, LR.Middle) - arr_str = print_arr(node.items_matrix) + arr_str = print_arr(node.items_grid) pc.pop_op() return arr_str diff --git a/src/pystencils/backend/kernelcreation/freeze.py b/src/pystencils/backend/kernelcreation/freeze.py index 8509712ca..0ae5a0d1b 100644 --- a/src/pystencils/backend/kernelcreation/freeze.py +++ b/src/pystencils/backend/kernelcreation/freeze.py @@ -296,7 +296,7 @@ class FreezeExpressions: f"Cannot translate nested arrays of non-uniform shape: {expr}" ) - return PsArrayInitList([s.items_matrix for s in subarrays]) # type: ignore + return PsArrayInitList([s.items_grid for s in subarrays]) # type: ignore else: # base case: no nested arrays return PsArrayInitList(items) diff --git a/src/pystencils/backend/kernelcreation/typification.py b/src/pystencils/backend/kernelcreation/typification.py index da05fdf4b..819d4a12b 100644 --- a/src/pystencils/backend/kernelcreation/typification.py +++ b/src/pystencils/backend/kernelcreation/typification.py @@ -220,9 +220,7 @@ class TypeContext: def _compatible(self, dtype: PsType): """Checks whether the given data type is compatible with the context's target type. - - If the target type is ``const``, they must be equal up to const qualification; - if the target type is not ``const``, `dtype` must match it exactly. + The two must match except for constness. """ assert self._target_type is not None return deconstify(dtype) == self._target_type @@ -267,11 +265,7 @@ class Typifier: **Typing of symbol expressions** - Some expressions (`PsSymbolExpr`, `PsArrayAccess`) encapsulate symbols and inherit their data types, but - not necessarily their const-qualification. - A symbol with non-``const`` type may occur in a `PsSymbolExpr` with ``const`` type, - and an array base pointer with non-``const`` base type may be nested in a ``const`` `PsArrayAccess`, - but not vice versa. + Some expressions (`PsSymbolExpr`, `PsArrayAccess`) encapsulate symbols and inherit their data types. """ def __init__(self, ctx: KernelCreationContext): -- GitLab