diff options
author | Nao Pross <np@0hm.ch> | 2024-06-07 16:28:05 +0200 |
---|---|---|
committer | Nao Pross <np@0hm.ch> | 2024-06-07 16:28:05 +0200 |
commit | 75c61877551a8a56dc37cc728c35ac03ac93c7e6 (patch) | |
tree | d82adad6a7723e7b929ee80932d4c36269f28adb | |
parent | Fix typos / bugs (diff) | |
download | sumofsquares-75c61877551a8a56dc37cc728c35ac03ac93c7e6.tar.gz sumofsquares-75c61877551a8a56dc37cc728c35ac03ac93c7e6.zip |
Improve __str__ methods of constraints
Diffstat (limited to '')
-rw-r--r-- | sumofsquares/constraints.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/sumofsquares/constraints.py b/sumofsquares/constraints.py index 844cc37..f287a23 100644 --- a/sumofsquares/constraints.py +++ b/sumofsquares/constraints.py @@ -54,7 +54,7 @@ class EqualToZero(Constraint[E]): @override def __str__(self): - return f"{self.__class__.__qualname__}: {str(self.expression)}" + return f"{str(self.expression)} = 0" @dataclassabc(frozen=True) @@ -82,7 +82,7 @@ class NonNegative(Constraint[E]): @override def __str__(self): - s = f"{self.__class__.__qualname__}: {str(self.expression)}" + s = f"{str(self.expression)} >= 0" if self.domain: s += f"\n\t\t over {self.domain}" return s @@ -93,6 +93,10 @@ class PositiveSemiDefinite(Constraint[E]): """ Constrain a matrix to be positive semidefinite. """ expression: E + @override + def __str__(self): + return f"{str(self.expression)} is PSD" + @dataclassabc(frozen=True) class ExponentialCone(Constraint[E]): @@ -106,6 +110,10 @@ class ExponentialCone(Constraint[E]): """ expression: E + @override + def __str__(self): + return f"{str(self.expression)} in ExpCone" + # TODO: Create missing classes below and add support in # - SOSProblem.apply |