diff options
author | Nao Pross <np@0hm.ch> | 2024-05-27 12:44:59 +0200 |
---|---|---|
committer | Nao Pross <np@0hm.ch> | 2024-05-27 13:02:32 +0200 |
commit | a25a52ad48a67d33fc4afd1f52b62f276ad52a01 (patch) | |
tree | 6898c73eaa35fe512008f7de35bc95e1485f1527 | |
parent | Expose more form_* functions to users (diff) | |
download | polymatrix-a25a52ad48a67d33fc4afd1f52b62f276ad52a01.tar.gz polymatrix-a25a52ad48a67d33fc4afd1f52b62f276ad52a01.zip |
Update comments and some __str__ methods
Diffstat (limited to '')
-rw-r--r-- | polymatrix/expression/impl.py | 7 | ||||
-rw-r--r-- | polymatrix/polymatrix/mixins.py | 5 |
2 files changed, 8 insertions, 4 deletions
diff --git a/polymatrix/expression/impl.py b/polymatrix/expression/impl.py index bbd932a..ac15aef 100644 --- a/polymatrix/expression/impl.py +++ b/polymatrix/expression/impl.py @@ -145,7 +145,7 @@ class DerivativeExprImpl(DerivativeExprMixin): return f"{self.__class__.__name__}(variables={self.variables}, underlying={repr(self.underlying)})" def __str__(self): - return f"∂_{self.variables} {self.underlying}" + return f"(∂_{self.variables} {self.underlying})" @dataclassabc.dataclassabc(frozen=True) @@ -463,6 +463,9 @@ class SubtractMonomialsExprImpl(SubtractMonomialsExprMixin): class SumExprImpl(SumExprMixin): underlying: ExpressionBaseMixin + def __str__(self): + return f"(Σ {self.underlying})" + @dataclassabc.dataclassabc(frozen=True) class SymmetricExprImpl(SymmetricExprMixin): @@ -489,7 +492,7 @@ class TransposeExprImpl(TransposeExprMixin): underlying: ExpressionBaseMixin def __str__(self): - return f"({self.underlying}).T" + return f"{self.underlying}.T" @dataclassabc.dataclassabc(frozen=True) diff --git a/polymatrix/polymatrix/mixins.py b/polymatrix/polymatrix/mixins.py index f5cdb48..c12f4cc 100644 --- a/polymatrix/polymatrix/mixins.py +++ b/polymatrix/polymatrix/mixins.py @@ -460,7 +460,8 @@ class PolyMatrixAsAffineExpressionMixin(PolyMatrixMixin, ABC): else: # TODO: document behaviour on why it is allowed to pass varirables - # it has to do with sumofsquares/solver/cvxopt.py + # it has to do with the function + # sumofsquares.problems.InternalSOSProblem.to_conic_problem variables = tuple(sorted(variables)) for degree in range(self.degree +1): @@ -504,7 +505,7 @@ class PolyMatrixAsAffineExpressionMixin(PolyMatrixMixin, ABC): # efficiency gain is useless if most of the computed terms are not # used. # TODO: tune heuristic - if len(self.slices) > (n / 2): + if len(self.slices) > n: # Compute all powers of x up to degree d all_monomials = self.monomials_eval_all(x) monomials = { |