From 2ad891b0d9f5d68f18fea1f166f27358a552ea86 Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Fri, 26 Apr 2024 13:23:17 +0200 Subject: Wrap raw dictionaries as PolyDict and PolyMatrixDict This is so that the old code is compatible with the new one --- polymatrix/polymatrix/init.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/polymatrix/polymatrix/init.py b/polymatrix/polymatrix/init.py index 6d9adaf..07ceb4c 100644 --- a/polymatrix/polymatrix/init.py +++ b/polymatrix/polymatrix/init.py @@ -8,6 +8,10 @@ def init_poly_matrix( data: PolyMatrixDict, shape: tuple[int, int], ): + # This is here because the old code in expression.mixins usually gives raw dictionaries + if not isinstance(data, PolyMatrixDict): + data = PolyMatrixDict(data) + return PolyMatrixImpl( data=data, shape=shape, @@ -18,6 +22,10 @@ def init_broadcast_poly_matrix( data: PolyDict, shape: tuple[int, int], ) -> BroadcastPolyMatrixMixin: + # This is here because the old code in expression.mixins usually gives raw dictionaries + if not isinstance(data, PolyDict): + data = PolyDict(data) + return BroadcastPolyMatrixImpl( data=data, shape=shape, -- cgit v1.2.1