summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNao Pross <np@0hm.ch>2024-05-09 15:32:08 +0200
committerNao Pross <np@0hm.ch>2024-05-09 15:32:08 +0200
commit53426a9c3e87eabae31bf591b025e6c6ceaeaf24 (patch)
treef52e8b586867b78afba6efb7c226e95e63277dd4
parentAdd helper method to PolyDict.constant to get constant term (diff)
downloadpolymatrix-53426a9c3e87eabae31bf591b025e6c6ceaeaf24.tar.gz
polymatrix-53426a9c3e87eabae31bf591b025e6c6ceaeaf24.zip
Add init_from_statemonad
Forgot to add to commit 573b7445866e1f870ebc1c0482114f1c19e2e7e0
Diffstat (limited to '')
-rw-r--r--polymatrix/expression/init.py7
1 files 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)