From 477d7aa799b93b63d03f50cb085e26597c21e04f Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Fri, 7 Jun 2024 11:21:34 +0200 Subject: Add more __str__ methods to Impl classes --- polymatrix/expression/impl.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/polymatrix/expression/impl.py b/polymatrix/expression/impl.py index 764cab8..81a624e 100644 --- a/polymatrix/expression/impl.py +++ b/polymatrix/expression/impl.py @@ -105,6 +105,9 @@ class ARangeExprImpl(ARangeExprMixin): class BlockDiagExprImpl(BlockDiagExprMixin): blocks: tuple[ExpressionBaseMixin, ...] + def __str__(self): + return f"blkdiag({self.underlying})" + @dataclassabc.dataclassabc(frozen=True) class CacheExprImpl(CacheExprMixin): @@ -153,6 +156,9 @@ class DerivativeExprImpl(DerivativeExprMixin): class DiagExprImpl(DiagExprMixin): underlying: ExpressionBaseMixin + def __str__(self): + return f"diag({self.underlying})" + @dataclassabc.dataclassabc(frozen=True) class DivergenceExprImpl(DivergenceExprMixin): @@ -174,6 +180,9 @@ class EvalExprImpl(EvalExprMixin): underlying: ExpressionBaseMixin substitutions: tuple + def __str__(self): + return f"eval({self.underlying}, {self.substitutions})" + @dataclassabc.dataclassabc(frozen=True) class EyeExprImpl(EyeExprMixin): @@ -278,6 +287,9 @@ class LinearMonomialsExprImpl(LinearMonomialsExprMixin): class LowerTriangularExprImpl(LowerTriangularExprMixin): underlying: ExpressionBaseMixin + def __str__(self): + return f"tril({self.underlying})" + @dataclassabc.dataclassabc(frozen=True) class LegendreSeriesImpl(LegendreSeriesMixin): @@ -437,6 +449,9 @@ class SliceExprImpl(SliceExprMixin): underlying: ExpressionBaseMixin slice: tuple # See SlicePolyMatrixMixin + def __str__(self): + return f"{self.underlying}[{self.slice}]" + @dataclassabc.dataclassabc(frozen=True) class SqueezeExprImpl(SqueezeExprMixin): -- cgit v1.2.1