Created
September 13, 2019 22:04
-
-
Save Upabjojr/f866ce14d3eee6b0dd5f28c340785814 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Replace with date and time the code was generated: | |
from generated_tempdir_2019_09_13_232810.generated_part000000 import match_root | |
from sympy import * | |
x = symbols("x") | |
def check_constraints(subst, constraints): | |
for cons in constraints: | |
ret = cons(**{k: v for k, v in subst.items() if k in cons.__code__.co_varnames}) | |
if not ret: | |
return False | |
return True | |
expr_list = [ | |
Integral(x, x), | |
Integral(x**2, x), | |
Integral(1/(1+x), x), | |
Integral(1/x, x), | |
Integral(sin(x), x), | |
Integral(sin(x)*cos(x), x), | |
] | |
for expr in expr_list: | |
g = match_root(expr) | |
ret = list(g) | |
results = [repl(**subst) for repl, subst, constraints in ret if check_constraints(subst, constraints)] | |
clean = [i for i in results if not isinstance(i, Function)] | |
pprint(expr) | |
pprint(clean) | |
print("===========================") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment