diff options
author | Nao Pross <np@0hm.ch> | 2024-05-09 19:51:26 +0200 |
---|---|---|
committer | Nao Pross <np@0hm.ch> | 2024-05-09 19:51:26 +0200 |
commit | 591a1a99ad7b76b659f06c14523b75bd55519bd9 (patch) | |
tree | 01b6a20340986101610c79f0bbd4329451b08349 | |
parent | Implement transformation using Positivstellensatz for constrained optimization (diff) | |
download | sumofsquares-591a1a99ad7b76b659f06c14523b75bd55519bd9.tar.gz sumofsquares-591a1a99ad7b76b659f06c14523b75bd55519bd9.zip |
Add __str__ to NonNegative constraint
Diffstat (limited to '')
-rw-r--r-- | sumofsquares/constraints.py | 9 |
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 |