summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNao Pross <np@0hm.ch>2024-05-09 19:51:26 +0200
committerNao Pross <np@0hm.ch>2024-05-09 19:51:26 +0200
commit591a1a99ad7b76b659f06c14523b75bd55519bd9 (patch)
tree01b6a20340986101610c79f0bbd4329451b08349
parentImplement transformation using Positivstellensatz for constrained optimization (diff)
downloadsumofsquares-591a1a99ad7b76b659f06c14523b75bd55519bd9.tar.gz
sumofsquares-591a1a99ad7b76b659f06c14523b75bd55519bd9.zip
Add __str__ to NonNegative constraint
Diffstat (limited to '')
-rw-r--r--sumofsquares/constraints.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/sumofsquares/constraints.py b/sumofsquares/constraints.py
index 41f2b14..37486e1 100644
--- a/sumofsquares/constraints.py
+++ b/sumofsquares/constraints.py
@@ -33,7 +33,8 @@ class ArchimedeanSet(Set):
polynomials: tuple[Expression]
def __str__(self):
- return f"{self.__class__.__qualname__}({', '.join(map(str, self.polynomials))})"
+ polynomials = ', '.join(map(str, self.polynomials))
+ return f"{self.__class__.__qualname__}({polynomials})"
@dataclassabc(frozen=True)
@@ -41,6 +42,10 @@ class EqualToZero(Constraint):
""" Constrain an expression to be equal to zero. """
expression: Expression
+ @override
+ def __str__(self):
+ return f"{self.__class__.__qualname__}: {str(self.expression)}"
+
@dataclassabc(frozen=True)
class NonNegative(Constraint):
@@ -59,7 +64,7 @@ class NonNegative(Constraint):
@override
def __str__(self):
- s = f"{self.__class__.__qualname__} {str(self.expression)}"
+ s = f"{self.__class__.__qualname__}: {str(self.expression)}"
if self.domain:
s += f"\n\t\t over {self.domain}"
return s