diff options
author | Nao Pross <np@0hm.ch> | 2024-05-27 10:37:22 +0200 |
---|---|---|
committer | Nao Pross <np@0hm.ch> | 2024-05-27 10:37:22 +0200 |
commit | 0e3973f69844ddb65e6329499a8a1f3de1bc65b5 (patch) | |
tree | eaa86364b853ebf9aa431f9bb7be8b1d94c45e68 | |
parent | Add mypy as (optional) dev dependency, limit python version to < 4.0 (diff) | |
download | polymatrix-0e3973f69844ddb65e6329499a8a1f3de1bc65b5.tar.gz polymatrix-0e3973f69844ddb65e6329499a8a1f3de1bc65b5.zip |
Fix bug in .diff() and add DerivativeExpr.__str__
Diffstat (limited to '')
-rw-r--r-- | polymatrix/expression/expression.py | 4 | ||||
-rw-r--r-- | polymatrix/expression/impl.py | 5 |
2 files changed, 6 insertions, 3 deletions
diff --git a/polymatrix/expression/expression.py b/polymatrix/expression/expression.py index 49164d0..58a3883 100644 --- a/polymatrix/expression/expression.py +++ b/polymatrix/expression/expression.py @@ -173,8 +173,8 @@ class Expression(ExpressionBaseMixin, ABC): def diff(self, variables: Expression, introduce_derivatives: bool | None = None) -> Expression: return self.copy( underlying=diff( - expression=self, - variables=variables, + expression=self.underlying, + variables=variables.underlying, introduce_derivatives=introduce_derivatives, ), ) diff --git a/polymatrix/expression/impl.py b/polymatrix/expression/impl.py index 65cc2fe..aedc7da 100644 --- a/polymatrix/expression/impl.py +++ b/polymatrix/expression/impl.py @@ -133,7 +133,7 @@ class ConcatenateExprImpl(ConcatenateExprMixin): @dataclassabc.dataclassabc(frozen=True) class DerivativeExprImpl(DerivativeExprMixin): underlying: ExpressionBaseMixin - variables: tuple + variables: ExpressionBaseMixin introduce_derivatives: bool stack: tuple[FrameSummary] @@ -141,6 +141,9 @@ class DerivativeExprImpl(DerivativeExprMixin): def __repr__(self): return f"{self.__class__.__name__}(variables={self.variables}, underlying={repr(self.underlying)})" + def __str__(self): + return f"∂_{self.variables} {self.underlying}" + @dataclassabc.dataclassabc(frozen=True) class DiagExprImpl(DiagExprMixin): |