From 5cab1e2d3e02fdeac7fdc538a0ead9617a3fdd1d Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Fri, 26 Apr 2024 13:20:59 +0200 Subject: Fix regression from splitting FromTuple mixin --- polymatrix/expression/init.py | 5 +++++ polymatrix/expression/mixins/fromnumbersexprmixin.py | 2 -- 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]: -- cgit v1.2.1