From adea19ba419da6f5cfd8a8256d167e9e138d8511 Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Sun, 3 Mar 2024 21:40:12 +0100 Subject: Add TODO & Warning for bug in Expr.replace --- mdpoly/abc.py | 10 ++++++++++ mdpoly/representations.py | 1 + 2 files changed, 11 insertions(+) diff --git a/mdpoly/abc.py b/mdpoly/abc.py index 1ceac87..618d3cd 100644 --- a/mdpoly/abc.py +++ b/mdpoly/abc.py @@ -73,6 +73,16 @@ class Expr(Protocol): It can also be used for more advanced replacements since ``old`` and ``new`` are free to be any expression. """ + # FIXME: this doesn't work if old is something like y ** 2, + # TODO: Define equality on expr object + if not isinstance(old, Leaf): + import warnings + warnings.warn( + "FIXME: You are trying to replace an expression with another " + "expression, but this does not work yet. Currently it is only " + "possible to replace leaves (Variable, Constant, Parameter) with " + "leaves / expressions.") + def replace_all(node): if node == old: return new diff --git a/mdpoly/representations.py b/mdpoly/representations.py index 802167b..da038bd 100644 --- a/mdpoly/representations.py +++ b/mdpoly/representations.py @@ -20,6 +20,7 @@ class HasRepr(Protocol): See also :py:class:`mdpoly.state.State`. """ + class SparseRepr(Repr): """ Sparse representation of polynomial. """ -- cgit v1.2.1