summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNao Pross <np@0hm.ch>2024-05-05 17:34:11 +0200
committerNao Pross <np@0hm.ch>2024-05-05 17:34:52 +0200
commit97afe9c971cdfe338946c94bcd4975d77495a735 (patch)
tree629ab7acbf005caf3c49f46420717ffea0f65811
parentFix bug introduced by backwards compatibility code (diff)
downloadpolymatrix-97afe9c971cdfe338946c94bcd4975d77495a735.tar.gz
polymatrix-97afe9c971cdfe338946c94bcd4975d77495a735.zip
Add more __str__ methods in expression implementations
-rw-r--r--polymatrix/expression/expression.py2
-rw-r--r--polymatrix/expression/impl.py12
-rw-r--r--polymatrix/expression/mixins/quadraticmonomialsexprmixin.py1
3 files changed, 11 insertions, 4 deletions
diff --git a/polymatrix/expression/expression.py b/polymatrix/expression/expression.py
index fbe7ac3..a0cf093 100644
--- a/polymatrix/expression/expression.py
+++ b/polymatrix/expression/expression.py
@@ -135,7 +135,7 @@ class Expression(ExpressionBaseMixin, ABC):
if left is None:
return NotImplemented
- return right.copy( underlying=op(left, right.underlying, stack))
+ return right.copy(underlying=op(left, right.underlying, stack))
def cache(self) -> "Expression":
return self.copy(
diff --git a/polymatrix/expression/impl.py b/polymatrix/expression/impl.py
index 03b4c2c..01f1e25 100644
--- a/polymatrix/expression/impl.py
+++ b/polymatrix/expression/impl.py
@@ -81,7 +81,7 @@ class AdditionExprImpl(AdditionExprMixin):
# implement custom __repr__ method that returns a representation without the stack
def __repr__(self):
- return f"{self.__class__.__name__}(left={self.left}, right={self.right})"
+ return f"{self.__class__.__name__}(left={repr(self.left)}, right={repr(self.right)})"
def __str__(self):
return f"({self.left} + {self.right})"
@@ -112,7 +112,7 @@ class DerivativeExprImpl(DerivativeExprMixin):
# implement custom __repr__ method that returns a representation without the stack
def __repr__(self):
- return f"{self.__class__.__name__}(variables={self.variables}, underlying={self.underlying})"
+ return f"{self.__class__.__name__}(variables={self.variables}, underlying={repr(self.underlying)})"
@dataclassabc.dataclassabc(frozen=True)
@@ -313,14 +313,20 @@ class QuadraticInExprImpl(QuadraticInExprMixin):
# implement custom __repr__ method that returns a representation without the stack
def __repr__(self):
- return f"{self.__class__.__name__}(variables={self.variables}, monomials={self.monomials}, underlying={self.underlying})"
+ return f"{self.__class__.__name__}(variables={self.variables}, monomials={self.monomials}, underlying={repr(self.underlying)})"
+
+ def __str__(self):
+ return f"QuadraticIn({str(self.underlying)}, {str(self.variables)})"
@dataclassabc.dataclassabc(frozen=True)
class QuadraticMonomialsExprImpl(QuadraticMonomialsExprMixin):
underlying: ExpressionBaseMixin
variables: tuple
+ def __str__(self):
+ return f"QuadraticMonomials({str(self.underlying)}, {str(self.variables)})"
+
@dataclassabc.dataclassabc(frozen=True)
class RepMatExprImpl(RepMatExprMixin):
diff --git a/polymatrix/expression/mixins/quadraticmonomialsexprmixin.py b/polymatrix/expression/mixins/quadraticmonomialsexprmixin.py
index 1066861..b6e671f 100644
--- a/polymatrix/expression/mixins/quadraticmonomialsexprmixin.py
+++ b/polymatrix/expression/mixins/quadraticmonomialsexprmixin.py
@@ -17,6 +17,7 @@ from polymatrix.polymatrix.utils.splitmonomialindices import split_monomial_indi
class QuadraticMonomialsExprMixin(ExpressionBaseMixin):
+ # FIXME: docstring, what does this thing even do
"""
Maps a polynomial matrix