diff options
-rw-r--r-- | polymatrix/expression/init.py | 5 | ||||
-rw-r--r-- | 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]: |