diff options
Diffstat (limited to 'examples/error_chain.py')
-rw-r--r-- | examples/error_chain.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/examples/error_chain.py b/examples/error_chain.py new file mode 100644 index 0000000..31a75ea --- /dev/null +++ b/examples/error_chain.py @@ -0,0 +1,26 @@ +try: + import mdpoly +except ModuleNotFoundError: + import sys + import pathlib + parent = pathlib.Path(__file__).resolve().parent.parent + sys.path.append(str(parent)) + +from mdpoly import State, Variable, Parameter +from mdpoly.representations import SparseRepr + +def make_invalid_expr(x, y): + return x ** (-4) + +def make_another_invalid(x, y): + return x ** -1 + +def make_ok_expr(x, y): + w = make_invalid_expr(x, y) + z = make_another_invalid(x, y) + return x + z + y + w + +x, y, z = Variable.from_names("x, y, z") + +bad = make_ok_expr(x, y) +bad.to_sparse(State()) |