New SymPy Gamma with Pyodide Implementation

289 views
Skip to first unread message

Aman Sharma

unread,
Feb 25, 2022, 12:32:27 AM2/25/22
to sympy
Hello everyone

I have been working on a pyodide implementation of SymPy Gamma. It is still currently very early WIP. 
It is currently available at https://mostlyaman.github.io/dev-sympy_gamma/
Eventually Sympy Gamma could also be hosted on a platform like Github Pages instead of Google App Engine

gamma.png

Since, it is not completed yet, it does not show output like previous sympy gamma. It currently renders the raw output in MathJax (if available) from SymPyGamma().eval() method . 
It also displays the data object received from the eval method. 


gamma2.png

Progress:

Considered Done
  • Make it look like gamma
  • Pyodide Implementation
  • Route Handling between components
  • Transfer input between routes
  • Web Worker Implementation and Loading Events
Work in Progress
  • MathJax Implementation (Some elements are being rendered by MathJax in the current demo.)
  • Complete Logic Implementation with Sympy Gamma (There is no proper documentation for sympy gamma, so it is taking time to implement.)
  • Better Error Handling
Further Implementations
  • Factor Tree Generator
  • Plotting
  • Get More digits Functionality
  • Integration Step Generation
  • Natural Language Processing
And a lot more....

Technical Details: 
It runs completely in the browser in a Web Worker Implementation of Pyodide so, the UI does not lag while Python is running on one thread.
The current technologies used are VueJS and Tailwind CSS and Vite for fast building during developement.
It runs on Sympy 1.9 and for generating output uses the code from app/logic directory from Sympy Gamma. I have created and used a whl of that directory as Pyodide can only load pure python packages from wheels.

Please share any opinions and ideas/features that would make a great addition to SymPy Gamma.

Aman Sharma

Qijia Liu

unread,
Feb 25, 2022, 8:52:36 AM2/25/22
to sympy
> It runs on Sympy 1.9 and for generating output uses the code from app/logic directory from Sympy Gamma. I have created and used a whl of that directory as Pyodide can only load pure python packages from wheels.

No, you are using code from kernel/gamma of SymPy Beta (https://github.com/eagleoflqj/sympy_beta).

Qijia Liu

Aman Sharma

unread,
Feb 25, 2022, 9:13:04 AM2/25/22
to sympy
You are correct. Thanks for pointing it out. I used the wheel from your project for while I was figuring out pyodide. I had changed it long ago as I remember, but  I did not realize that I was still using this one. I am updating it asap.

Aman Sharma

unread,
Feb 25, 2022, 10:25:01 AM2/25/22
to sympy
I have changed the wheel and the demo now uses code from Original SymPy gamma.

Aman Sharma

Aman Sharma

unread,
Mar 12, 2022, 1:52:12 AM3/12/22
to sympy

Hello everyone
I have made some progress with SymPy Gamma on Pyodide. The only major thing not implemented is Plotting. If you are interested, please check out the demo and leave your thoughts.
https://mostlyaman.github.io/dev-sympy_gamma/

A major hurdle in the progress is upgrading the sympy gamma logic code to sympy 1.9 API, and since there is no documentation, it will take quite a bit of work. 
Plotting is expected to be implemented soon. Apart from that, it works fine most of time but it can still fail and throw errors sometimes. It will be more reliable once we update the gamma logic code as previously mentioned. 

You can open browser devtools Console to look for errors. It will log the python traceback to console if any error occurs.

Aman Sharma

Oscar Benjamin

unread,
Mar 16, 2022, 6:37:02 PM3/16/22
to sympy
On Sat, 12 Mar 2022 at 06:52, Aman Sharma
<b21...@students.iitmandi.ac.in> wrote:
>
>
> Hello everyone
> I have made some progress with SymPy Gamma on Pyodide. The only major thing not implemented is Plotting. If you are interested, please check out the demo and leave your thoughts.
> https://mostlyaman.github.io/dev-sympy_gamma/
>
> A major hurdle in the progress is upgrading the sympy gamma logic code to sympy 1.9 API, and since there is no documentation, it will take quite a bit of work.

Is the SymPy 1.9 API that different? What is it that needs work?

--
Oscar

Aman Sharma

unread,
Mar 17, 2022, 5:47:09 AM3/17/22
to sympy
The API is probably not that different. I was a little lost earlier going through logic, and I was getting errors like this.
1.png

So, I changed it to return sympy.integrals.manualintegrate.manualintegrate and the error was not raised.
So I thought it may be a API change and there may be other errors like these.
but It is probably not the API since I have checked sympy 1.5 and the directory structure is the same. So, did this not give errors with sympy 1.5?
It is probably not updating the API that needs work.

The major change in gamma is probably mathjax implementation, it uses script tags right now and I believe that Mathjax 3 does not support rendering script tags by default. 
Since sympy can produce latex expressions, I thought it would be better to change gamma to use delimitters rather than script tags(?)

The next thing that needs to be done is working on "options".
Like this in the integrals.
2.png

Then there is plotting which would also require D3js. Integral steps and factorization diagrams will follow.

For me, the biggest hurdle right now is understanding how to interface with gamma and without any documentation, it is taking time.
It would be a huge help if someone familiar with gamma could help with this.

Aman Sharma
Reply all
Reply to author
Forward
0 new messages