summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNao Pross <np@0hm.ch>2024-04-26 13:20:59 +0200
committerNao Pross <np@0hm.ch>2024-04-26 13:20:59 +0200
commit5cab1e2d3e02fdeac7fdc538a0ead9617a3fdd1d (patch)
tree9b4394e8e7895c6c85d3dc7ccf93238dbe453dfe
parentMake is_constant for MonomialIndex and VariableIndex static methods (diff)
downloadpolymatrix-5cab1e2d3e02fdeac7fdc538a0ead9617a3fdd1d.tar.gz
polymatrix-5cab1e2d3e02fdeac7fdc538a0ead9617a3fdd1d.zip
Fix regression from splitting FromTuple mixin
-rw-r--r--polymatrix/expression/init.py5
-rw-r--r--polymatrix/expression/mixins/fromnumbersexprmixin.py2
2 files changed, 5 insertions, 2 deletions
diff --git a/polymatrix/expression/init.py b/polymatrix/expression/init.py
index 5acb40d..83ee26f 100644
--- a/polymatrix/expression/init.py
+++ b/polymatrix/expression/init.py
@@ -180,6 +180,11 @@ def init_from_expr_or_none(
name=data,
)
+ elif isinstance(data, int | float):
+ # Wrap in a tuple of tuples
+ wrapped = ((data,),)
+ 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))
diff --git a/polymatrix/expression/mixins/fromnumbersexprmixin.py b/polymatrix/expression/mixins/fromnumbersexprmixin.py
index c35f955..397f6c5 100644
--- a/polymatrix/expression/mixins/fromnumbersexprmixin.py
+++ b/polymatrix/expression/mixins/fromnumbersexprmixin.py
@@ -22,8 +22,6 @@ class FromNumbersExprMixin(ExpressionBaseMixin):
@abstractmethod
def data(self) -> tuple[tuple[int | float]]:
""" The matrix of numbers in row major order. """
- # TODO: allow numbers tuple, interpreted as row vector and just
- # numbers, interpreted as scalars
@override
def apply(self, state: ExpressionStateMixin) -> tuple[ExpressionStateMixin, PolyMatrixMixin]: