diff options
author | Nao Pross <np@0hm.ch> | 2024-05-07 16:42:32 +0200 |
---|---|---|
committer | Nao Pross <np@0hm.ch> | 2024-05-07 16:42:32 +0200 |
commit | 2a9adda82b281defbad3e246c6122282c9c2ab2c (patch) | |
tree | 394d32626bbe6284847b1d1ce8eb94bf2457a361 | |
parent | Improve docstring (diff) | |
download | polymatrix-2a9adda82b281defbad3e246c6122282c9c2ab2c.tar.gz polymatrix-2a9adda82b281defbad3e246c6122282c9c2ab2c.zip |
Fix bug in v_stack that creates unnecessary Expressions, add __str__ to combinations
-rw-r--r-- | polymatrix/expression/__init__.py | 2 | ||||
-rw-r--r-- | polymatrix/expression/impl.py | 5 |
2 files changed, 6 insertions, 1 deletions
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): |