diff options
author | Nao Pross <np@0hm.ch> | 2024-03-03 21:40:12 +0100 |
---|---|---|
committer | Nao Pross <np@0hm.ch> | 2024-03-03 21:40:12 +0100 |
commit | adea19ba419da6f5cfd8a8256d167e9e138d8511 (patch) | |
tree | de4c9850de1ffcb56daa20bf8816de7f35c1a8b7 | |
parent | Make State.from_index accept PolyVarIndex indices (diff) | |
download | mdpoly-adea19ba419da6f5cfd8a8256d167e9e138d8511.tar.gz mdpoly-adea19ba419da6f5cfd8a8256d167e9e138d8511.zip |
Add TODO & Warning for bug in Expr.replace
Diffstat (limited to '')
-rw-r--r-- | mdpoly/abc.py | 10 | ||||
-rw-r--r-- | mdpoly/representations.py | 1 |
2 files changed, 11 insertions, 0 deletions
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. """ |