diff options
author | Nao Pross <np@0hm.ch> | 2024-04-26 13:23:17 +0200 |
---|---|---|
committer | Nao Pross <np@0hm.ch> | 2024-04-26 13:23:17 +0200 |
commit | 2ad891b0d9f5d68f18fea1f166f27358a552ea86 (patch) | |
tree | 78e3e94d91465c4d4112e7ed663c309917d91987 | |
parent | Fix regression from splitting FromTuple mixin (diff) | |
download | polymatrix-2ad891b0d9f5d68f18fea1f166f27358a552ea86.tar.gz polymatrix-2ad891b0d9f5d68f18fea1f166f27358a552ea86.zip |
Wrap raw dictionaries as PolyDict and PolyMatrixDict
This is so that the old code is compatible with the new one
-rw-r--r-- | polymatrix/polymatrix/init.py | 8 |
1 files changed, 8 insertions, 0 deletions
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, |