sympy_gamma
sympy_gamma copied to clipboard
Ipython notebook page
Firstly, this in no way is completed.This is just the basic structure on which we can inplement ipython notebook.I have actually the main thing to write. I have done several things because i felt them to be good so please help me out where you feel that something needs to be changed. Following are the points which i have applied or thought: 1)I have used 'r' variable from views.input and parsed it with notebook.py file which have all the formats predefined and i just childishly changed their values and appended. 2)That result variable is passed in the url. i know that there is a maximum length of url but i thought it will large enough to not exceed. 3)I didn't stored the result into the databases because it is not free and if i can use something else why should i use them. 4)Plotting and cards are to be implemented and after that this will be very cool because the possibilities are just endless 5)i have a view which renders the json and i have given the link to the nbviewer which renders out json.
Demo: http://sympygamma-pr-32.appspot.com
Overall, this is a good start. The notebook JSON is being generated correctly (I think), but there are little issues preventing it from working. I've put up a demo but it raises an exception.
Thank you David for pointing out these issues to me. I will be commiting these changes along with the ability to create a gist and create a complete JSON. Right now i am working on creating Plots into notebook. Thanks a lot
Let's definitely not store things in the database. The database size is limited, and I really don't want to have to wipe everyone's notebooks when it fills up.
ok! we will not use databases.. thats why we are trying to export them to GIST.
Have not added the codes on which i am working ( exporting notebook to GIST and plotting)but have cleaned up the code a bit.
hey David and Aaron, i was thinking to work on sympy_gamma and sympy_live fulltime by participating in GSOC. Is Anyone of you thinking to be or will be the mentor for this project..and if not do you happen to know who might be interested?
@sahilshekhawat --- if we get accepted as an organization, you can then send a proposal, or work with Aaron or David to create one.
thanks Ondřej! :) and also i am having some problem if you can lend me some time it will be very helpful https://groups.google.com/forum/#!topic/sympy/O1FJyh5bOZ0
I would advise using a different method than passing the result dictionary back to the result.ipynb
view, because it's causing HTTP 414 errors (the request is too long). Instead, pass the input string to the view and parse/generate the result again (yes, this will duplicate the calculation, unfortunately) OR generate the JSON with the result and just include it with each request OR generate and store the JSON in a Gist.
I have now changed the code, it is passing the input string (without encoding) as GET parameter and SymPyGamma is again calculating the results. Now to the exporting to GIST, i think that will be the central idea of implementing ipython notebook so that users can share their results as well. i am currently working to embedd GITHUB API into out codes. It will be really a nice addon
About the issue with \\
: the behavior is correct. \frac
, when encoded as json, will result in the string "\\frac"
, and this should display to the user, because JSON requires that the \
in \frac
be escaped, thus \\frac
appears in the output.
Oh! seems like i was worrying for no reason. But i had copied the output to the GIST saved it and then rendered it with NBVIEWER, there it was not showing the latex correctly.
You need to strip the <script>
tags surrounding the LaTeX.
And replace them with $$
.
(I think).
Guess what! i have already done that, but that will cause an problem when there is a table like structure to be rendered as latex..for which the html tags are used.
And that too didn't freed me from double backslashes
The double backslashes are fine in the JSON. If you're stripping tags, only strip the script tags.
Also, is it necessary to tell IPython that the cell contains LaTeX?
well, if mathjax is into script tags then it renders them anyway but after striping them we need to add $$ to the ends like you said to render it as LaTeX.
Thanks David, I have tried it and it is rendering correctly. :+1:
Now, i have to implement plotting into it and rendering the steps..
Demo: http://32.sympy-gamma-li.appspot.com/
The JSON generation is producing an invalid result:
- http://nbviewer.ipython.org/url/32.sympy-gamma-li.appspot.com/result.ipynb?input=integrate(2*x%20+%20y,%20(x,%201,%203))
- http://nbviewer.ipython.org/url/32.sympy-gamma-li.appspot.com/result.ipynb/?i=summation(1/2**i,%20(i,%200,%20oo))
The bug seems to be that newlines are not being escaped in the output, leading to invalid JSON.
Other things I noticed during testing:
- IPython expects the JSON to be correctly indented. So use
json.dumps(..., indent=4)
. - Characters must be escaped; use
str(...).encode('string_escape')
. - On the JSON result page, style the
body
element withwhite-space: pre;
so that spaces are preserved in the output for the viewer.
Oh, and all the results are empty.
Some of the output cells are being treated as headings.
David, i copied all the json for the same input and then saved it gist..there it is rendering into nbviewer...
I have not yet completed including the output of 'cards' thats why most of the outputs are empty.
I have also setup a demo at http://sympygamma.appspot.com . Giving the url of the json generated to nbviewer gives an error because all the basic tags of html are included which are conflicting with the format. But saving it to the gist and then opening them with nbviewer works fine. i will include the github api to export it to GIST and after that we can merge the codes.