aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNao Pross <np@0hm.ch>2024-03-03 21:40:12 +0100
committerNao Pross <np@0hm.ch>2024-03-03 21:40:12 +0100
commitadea19ba419da6f5cfd8a8256d167e9e138d8511 (patch)
treede4c9850de1ffcb56daa20bf8816de7f35c1a8b7
parentMake State.from_index accept PolyVarIndex indices (diff)
downloadmdpoly-adea19ba419da6f5cfd8a8256d167e9e138d8511.tar.gz
mdpoly-adea19ba419da6f5cfd8a8256d167e9e138d8511.zip
Add TODO & Warning for bug in Expr.replace
-rw-r--r--mdpoly/abc.py10
-rw-r--r--mdpoly/representations.py1
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. """