From 53426a9c3e87eabae31bf591b025e6c6ceaeaf24 Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Thu, 9 May 2024 15:32:08 +0200 Subject: Add init_from_statemonad Forgot to add to commit 573b7445866e1f870ebc1c0482114f1c19e2e7e0 --- polymatrix/expression/init.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/polymatrix/expression/init.py b/polymatrix/expression/init.py index 1e5baab..bb3da9a 100644 --- a/polymatrix/expression/init.py +++ b/polymatrix/expression/init.py @@ -157,6 +157,10 @@ def init_from_sympy_expr(data: sympy.Expr | sympy.Matrix | tuple[tuple[sympy.Exp return polymatrix.expression.impl.FromSympyExprImpl(data=data) +def init_from_statemonad(monad: StateMonad): + return polymatrix.expression.impl.FromStateMonadImpl(monad=monad) + + # NP: this function should be split up into smaller functions, one for each "from" type # NP: and each "from" should be documented, explaining how it is interpreted. def init_from_expr_or_none( @@ -177,8 +181,7 @@ def init_from_expr_or_none( return init_from_numbers_expr(wrapped) elif isinstance(data, StateMonad): - # FIXME: typing - return data.flat_map(lambda inner_data: init_from_expr_or_none(inner_data)) + return init_from_statemonad(data) elif isinstance(data, np.ndarray): return init_from_numpy_expr(data) -- cgit v1.2.1