summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNao Pross <np@0hm.ch>2024-05-07 16:42:32 +0200
committerNao Pross <np@0hm.ch>2024-05-07 16:42:32 +0200
commit2a9adda82b281defbad3e246c6122282c9c2ab2c (patch)
tree394d32626bbe6284847b1d1ce8eb94bf2457a361
parentImprove docstring (diff)
downloadpolymatrix-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__.py2
-rw-r--r--polymatrix/expression/impl.py5
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):