-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show ReplacementRule while using replace()
in ManyToOneReplacer
#10
Comments
replace()
in ManyToOneReplacerreplace()
in ManyToOneReplacer
You can use the underlying matcher to find out which rules match: |
I have used the following code: matches = rubi.matcher.match(expr)
for matched_pattern, substitution in sorted(map(lambda m: (str(m[0]), str(m[1])), matches)):
print('{} matched with {}'.format(matched_pattern, substitution)) which returns: <function rubi_object.<locals>.<lambda> at 0x10bf93d08> matched with {x ↦ x} What do I need to do in order to print the ReplacementRule? |
Sorry, I didn't realize that the labels used by the matches = rubi.matcher.match(expr)
for _ in matches._match(rubi.matcher.root):
for pattern_index in matches.patterns:
renaming = rubi.matcher.pattern_vars[pattern_index]
substitution = matches.substitution.rename({renamed: original for original, renamed in renaming.items()})
pattern = rubi.matcher.patterns[pattern_index][0]
print('{} matched with {}'.format(pattern , substitution)) I will try to add some debugging functionality to the |
Thanks |
It would be nice to have API something like this: result, applied_rule = replacer.replace(expression, showsteps=True) Otherwise we would have to compute the |
Is it possible to know/display the
ReplacementRule
if thereplace()
is able apply the rule?The text was updated successfully, but these errors were encountered: