Skip to content
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

code generation for rubi - continue #14988 #17065

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Shekharrajak
Copy link
Member

References to other Issues or PRs

Continuation of #14988

Brief description of what is fixed or changed

Trying out codegen writtein in #14988 with new MatchPy and modifying it accordingly.

Other comments

# Name                    Version                   Build  Channel
matchpy                   0.5.1                    pypi_0    pypi

Release Notes

  • integrals.rubi
    • Code Generation for Rubi

@sympy-bot
Copy link

Hi, I am the SymPy bot (v147). I'm here to help you write a release notes entry. Please read the guide on how to write release notes.

❌ There was an issue with the release notes. Please do not close this pull request; instead edit the description after reading the guide on how to write release notes.

  • integrals.rubi is not a valid release notes header. Release notes headers should be SymPy submodule names, like

    * core
      * made Add faster
    
    * printing
      * improve LaTeX printing of fractions
    

    or other.

    If you have added a new submodule, please add it to the list of valid release notes headers at https://github.com/sympy/sympy-bot/blob/master/sympy_bot/submodules.txt.

Note: This comment will be updated with the latest check if you edit the pull request. You need to reload the page to see it.

Click here to see the pull request description that was parsed.

#### References to other Issues or PRs

Continuation of #14988

#### Brief description of what is fixed or changed

Trying out codegen writtein in #14988 with new MatchPy and modifying it accordingly.

#### Other comments

```
# Name                    Version                   Build  Channel
matchpy                   0.5.1                    pypi_0    pypi

```


#### Release Notes

<!-- Write the release notes for this release below. See
https://github.com/sympy/sympy/wiki/Writing-Release-Notes for more information
on how to write release notes. The bot will check your release notes
automatically to see if they are formatted correctly. -->

<!-- BEGIN RELEASE NOTES -->

- integrals.rubi
     * Code Generation for Rubi

<!-- END RELEASE NOTES -->

@Shekharrajak
Copy link
Member Author

@Upabjojr , I created this PR to check for latest matchpy version. I tried to cherry-pick Ashish's commit but when I updated with latest master branch, I messed with conflicts. So here I am directly using the codegen file in latest master branch of SymPy.

@Shekharrajak
Copy link
Member Author

Here is the example I tried :

>>> from sympy.integrals.rubi import codegen
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/shekharrajak/Documents/sympy/sympy/sympy/integrals/rubi/codegen.py", line 57, in <module>
    generator = RubiCodeGenerator(rubi)
  File "/home/anaconda3/envs/sympy-dev/lib/python3.7/site-packages/matchpy/matching/code_generation.py", line 28, in __init__
    self._patterns = set(range(len(matcher.patterns)))
AttributeError: 'ManyToOneReplacer' object has no attribute 'patterns'

@Upabjojr
Copy link
Contributor

The code generator works on the ManyToOneMatcher object. You should extract it from the ManyToOneReplacer.

@Upabjojr
Copy link
Contributor

I have extracted the ManyToOneMatcher. There are still problems related to the constraints and lambdas, they should be fixed.

@Upabjojr
Copy link
Contributor

I have disabled most of the rules. It is now possible to do experiments in reasonable time.

@Upabjojr
Copy link
Contributor

OK, I think I see what the problems are:

  • the replacement functions are defined as local functions inside the functions loading the rules (e.g. replacement rule number 1). The rules are generated, so it's a problem with the generator.
  • the constraint printer is unable to handle ordinary function. The function constraint_repr in RubiCodeGenerator should be modified accordingly. I believe you should start by returning return constraint.constraint.__name__, False or something similar.

@Upabjojr
Copy link
Contributor

In particular, the first part requires to redesign the code generator, which may be tedious.

@Upabjojr
Copy link
Contributor

If you have Wolfram Mathematica installed, try to follow: https://github.com/sympy/sympy/wiki/Rubi-parsing-guide

@Upabjojr
Copy link
Contributor

Here we go again:
https://github.com/Upabjojr/RUBI-4.10-parsed

@Upabjojr
Copy link
Contributor

I've just noticed a mistake. Correcting wrong documentation #17101

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants