From 2a9adda82b281defbad3e246c6122282c9c2ab2c Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Tue, 7 May 2024 16:42:32 +0200 Subject: Fix bug in v_stack that creates unnecessary Expressions, add __str__ to combinations --- polymatrix/expression/__init__.py | 2 +- polymatrix/expression/impl.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/polymatrix/expression/__init__.py b/polymatrix/expression/__init__.py index b150cc5..f8b5b74 100644 --- a/polymatrix/expression/__init__.py +++ b/polymatrix/expression/__init__.py @@ -17,7 +17,7 @@ def v_stack( if isinstance(expr, Expression): yield expr.underlying else: - yield polymatrix.expression.from_.from_(expr) + yield polymatrix.expression.from_.from_(expr).underlying return init_expression( underlying=polymatrix.expression.impl.VStackExprImpl( diff --git a/polymatrix/expression/impl.py b/polymatrix/expression/impl.py index ad09853..0ddda2e 100644 --- a/polymatrix/expression/impl.py +++ b/polymatrix/expression/impl.py @@ -102,6 +102,11 @@ class CombinationsExprImpl(CombinationsExprMixin): expression: ExpressionBaseMixin degrees: tuple[int, ...] + def __str__(self): + if len(self.degrees) == 1: + return f"combinations({self.expression}, {self.degrees[0]})" + return f"combinations({self.expression}, {self.degrees})" + @dataclassabc.dataclassabc(frozen=True) class DerivativeExprImpl(DerivativeExprMixin): -- cgit v1.2.1