sympy_gamma icon indicating copy to clipboard operation
sympy_gamma copied to clipboard

Ipython notebook page

Open sahilshekhawat opened this issue 11 years ago • 102 comments

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

sahilshekhawat avatar Feb 07 '14 14:02 sahilshekhawat

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.

lidavidm avatar Feb 08 '14 21:02 lidavidm

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

sahilshekhawat avatar Feb 09 '14 03:02 sahilshekhawat

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.

asmeurer avatar Feb 10 '14 01:02 asmeurer

ok! we will not use databases.. thats why we are trying to export them to GIST.

sahilshekhawat avatar Feb 10 '14 04:02 sahilshekhawat

Have not added the codes on which i am working ( exporting notebook to GIST and plotting)but have cleaned up the code a bit.

sahilshekhawat avatar Feb 10 '14 11:02 sahilshekhawat

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 avatar Feb 14 '14 23:02 sahilshekhawat

@sahilshekhawat --- if we get accepted as an organization, you can then send a proposal, or work with Aaron or David to create one.

certik avatar Feb 14 '14 23:02 certik

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

sahilshekhawat avatar Feb 14 '14 23:02 sahilshekhawat

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.

lidavidm avatar Feb 15 '14 00:02 lidavidm

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

sahilshekhawat avatar Feb 15 '14 01:02 sahilshekhawat

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.

lidavidm avatar Feb 15 '14 01:02 lidavidm

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.

sahilshekhawat avatar Feb 15 '14 01:02 sahilshekhawat

You need to strip the <script> tags surrounding the LaTeX.

lidavidm avatar Feb 15 '14 01:02 lidavidm

And replace them with $$.

lidavidm avatar Feb 15 '14 01:02 lidavidm

(I think).

lidavidm avatar Feb 15 '14 01:02 lidavidm

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.

sahilshekhawat avatar Feb 15 '14 01:02 sahilshekhawat

And that too didn't freed me from double backslashes

sahilshekhawat avatar Feb 15 '14 01:02 sahilshekhawat

The double backslashes are fine in the JSON. If you're stripping tags, only strip the script tags.

lidavidm avatar Feb 15 '14 01:02 lidavidm

Also, is it necessary to tell IPython that the cell contains LaTeX?

lidavidm avatar Feb 15 '14 01:02 lidavidm

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.

sahilshekhawat avatar Feb 15 '14 01:02 sahilshekhawat

Thanks David, I have tried it and it is rendering correctly. :+1:

sahilshekhawat avatar Feb 15 '14 02:02 sahilshekhawat

Now, i have to implement plotting into it and rendering the steps..

sahilshekhawat avatar Feb 15 '14 02:02 sahilshekhawat

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))

lidavidm avatar Feb 16 '14 17:02 lidavidm

The bug seems to be that newlines are not being escaped in the output, leading to invalid JSON.

lidavidm avatar Feb 16 '14 17:02 lidavidm

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 with white-space: pre; so that spaces are preserved in the output for the viewer.

lidavidm avatar Feb 16 '14 17:02 lidavidm

Oh, and all the results are empty.

lidavidm avatar Feb 16 '14 17:02 lidavidm

Some of the output cells are being treated as headings.

lidavidm avatar Feb 16 '14 17:02 lidavidm

David, i copied all the json for the same input and then saved it gist..there it is rendering into nbviewer...

sahilshekhawat avatar Feb 16 '14 17:02 sahilshekhawat

I have not yet completed including the output of 'cards' thats why most of the outputs are empty.

sahilshekhawat avatar Feb 16 '14 17:02 sahilshekhawat

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.

sahilshekhawat avatar Feb 17 '14 10:02 sahilshekhawat