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
Notebook bug fix branch #1361
Notebook bug fix branch #1361
Conversation
* Refactored the save widget so that the notebook doesn't depend on it. Now the notebook emits events and the save widget observes those events. * Created a new event system for all IPython events (events.js). We should start to use this to allow our classes to be loosely coupled. * Created a new notification widget that should be used for all notifications. Uses new event system. * Removed the kernel status widget. * All kernel status message use new event/notification system. * The print notebook view works again.
* Test suite passes. * nbformat put into a single location for easy update.
Hitting Shift-Enter on an already rendered text cell should simply move past it. It was causing the cell to enter edit mode. This is not fixed.
Previuosly we were using itex=True in the sympy latex printer. I don't know why where were doing this but we should use regular printing mode and put the $$ around the equations ourselves.
Pressing TAB to get the tooltip "range(TAB" was inserting a TAB. To get rid of this we are now telling CodeMirror to ignore it and also stopping the event from bubbling up the DOM.
@@ -123,6 +123,10 @@ var IPython = (function (IPython) { | |||
return false; | |||
} else if ((pre_cursor.substr(-1) === "("|| pre_cursor.substr(-1) === " ") && tooltip_on_tab ) { | |||
that.request_tooltip_after_time(pre_cursor,0); | |||
// Prevent the event from bubbling up. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1. Users are warned when an older nbformat notebook is converted. 2. The notebook notifies the user when a notebook that is too new is attempted to load. To test these things, create a simple notebook. Then change its nbformat field by hand to 2 (to test 1) and then 4 (to test 2).
OK, this is ready for review. @fperez, @Carreau, @takluyver, @minrk can you test this, the changes are significant and many bugs are fixed (list above). |
Looking great so far, all but the mathjax bug seem completely gone; for that one I still see a slight glitch, best explained with an image: <img src="http://img94.imageshack.us/img94/3061/selection001x.png" /img> The dollar signs shouldn't be there, though I don't know if that is somehow a sympy issue instead. I just want to point it out for now. I haven't reviewed the code yet, but behavior-wise this is major progress, thanks a lot! |
Won't have time in the next 24h ... see maybe tomorow. i'ts on my to-do list. |
I'm not seeing the issue @fperez is having with dollar signs. I'm using Firefox 9.0.1, Sympy 0.7.1 and I started the notebook with |
When I run notebook in Epiphany 3.2.1 browser,
And I am indeed not able to run code - I entered Epiphany is great for IPython notebooks because it has a web application mode which makes IPython notebook behave like any other (native desktop) application you have installed - it appears in dash, application lists, etc. Edit: Notebook doesn't work in Epiphany in master too. I am pretty sure that it worked a couple of days ago though. |
Miha, the notebook will only work in modern browsers which support |
@fperez: I don't see this issue with the dollar signs either. This was on both Chrome and FF on Mac OS X. I am wondering if it is a MathJax version issue. Of what vintage is your MathJax - mine is late summer. |
Mmh, that's quite odd. Just to be safe, I've re-downloaded mathjax with a fresh copy from their site and re-installed locally, and I've tested both Ffox and Chrome. I see those $ signs in both browsers (after multiple javascript reloads). It's really bizarre. On the one hand I am not using sympy so much that this is a huge deal for me (I hadn't seen the issue in the first place), but on the other, if I see the problem, chances are someone else out there will too. So it really would be better to get to the bottom of it. It almost looks as if we were inserting extra $ signs... If I manually call
|
On Thu, Feb 2, 2012 at 9:02 AM, Fernando Perez
Hmm, that is a puzzle.
Yes, what about other types of sympy expressions? Is this problem
Yes, that is what I am thinking. I will give you some JS code to
Brian E. Granger |
@fperez: here is the code to type into the console: IPython.notebook.get_cell(1).outputs[0] This assumes that the cell with the output is cell 1 (0-indexed) and that there is one output. It will give you a JS object you can introspect. There will be a latex attribute that has the raw text that was returned by the server. |
OK, the problem is actually in all sympy expressions:
I double-checked, and with master it's OK, no spurious $ signs anywhere. They only show up with this branch. |
Yup, I just typed
so there seem to be indeed spurious $ in there. |
OK, now let's track down where the extra $ is coming from. In the def print_latex(o): You can see where we are adding the double pair if $$. You can call latex(3**(S(1)/4)) Try that on a few expressions - it comes back with no $ on my system. On Thu, Feb 2, 2012 at 9:22 AM, Fernando Perez
Brian E. Granger |
@fperez: let's pull up IRC and figure this out. On Thu, Feb 2, 2012 at 9:26 AM, Brian Granger ellisonbg@gmail.com wrote:
Brian E. Granger |
Will hop on irc now... The problem may be a sympy version issue... |
Older versions of sympy put in an extra $ when using latex(e, mode='plain'). We are removing those before we add our own to make sure it works.
* Math now adds $$ if the user doesn't provide them. * Latex is like Math, but doesn't add delimiters.
Just to confirm for the PR record, that with the updates discussed on IRC to |
Just for the record: It turns out that the Tornado upgrade (2.1.1 -> 2.2) broke notebooks in Epiphany. With tornado 2.1.1 both master and nbissues branches work fine in Epiphany. I sent mail to Epiphany mailing list and i hope that they figure out why Tornado 2.2 (which was released on jan 30) is causing problems. |
// Persistance and loading | ||
|
||
Notebook.prototype.get_notebook_id = function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it really necessary to have explicit getters and setters? I'm just curious: in Java/C++ they are ubiquitous, in Python rarely used. I just don't know if JS really requires them, and what the issues may be with explicitly setting the attribute from the outside. Basically, does the extra indirection layer really buy us anything?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure what the usual patterns are in Javascript. It is surely more like Python than Java/C++. In this case, it was a gut feel that I wanted a layer of abstraction, in case I needed to ever change how the attribute was handled. I haven't done many of these though and I guess you could argue that it is not needed yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the principal reason is that there is no equivalent of @property
. If it seems like changing the notebook name might have side effects (even if it doesn't start out with any), it should be a setter because you can't turn an attribute into a property without changing the API, unlike in Python.
I think it's a minor style issue really, but that's the usual motivation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, it's no big deal and I don't have any major objection, really. Since we're all finding our way through JS, I'm sure we'll learn more and will find our own style over time. I think it's fine to leave these as-is for now, following your instinct.
I'll merge now then, since we're good on review and you updated the example nb, which was the last point in my mind. Thanks for the great job, this fixes a number of key issues!
A number of bug fixes for notebook issues that had crept up recently with all the major improvements done on multiple fronts. In closing #1359, we've changed slightly how Math() works: it now unconditionally surrounds its input with $$...$$, so that it always appears in displayed math mode. We have also introduced a new display object, Latex(), which does *not* add any latex markup, for other constructs beyond simple math expressions. This change makes Math() friendlier to use in simple cases and means that Math(sympy.latex(foo)) will produce the expected displayed math results without the user having to add any $ markup. Summary of fixes: Fixes #1344: Ctrl + M + L does not toggle line numbering in htmlnotebook. Fixes #1337: Tab in the notebook after `(` should not indent, only give a tooltip. Fixes #1339: Notebook printing broken. Fixes #1348: `Ctrl-m-Ctrl-m` does not switch to markdown cell Fixes #1359: [sympyprinting] MathJax can't render \root{m}{n}
Merged, thanks @ellisonbg!! |
A number of bug fixes for notebook issues that had crept up recently with all the major improvements done on multiple fronts. In closing ipython#1359, we've changed slightly how Math() works: it now unconditionally surrounds its input with $$...$$, so that it always appears in displayed math mode. We have also introduced a new display object, Latex(), which does *not* add any latex markup, for other constructs beyond simple math expressions. This change makes Math() friendlier to use in simple cases and means that Math(sympy.latex(foo)) will produce the expected displayed math results without the user having to add any $ markup. Summary of fixes: Fixes ipython#1344: Ctrl + M + L does not toggle line numbering in htmlnotebook. Fixes ipython#1337: Tab in the notebook after `(` should not indent, only give a tooltip. Fixes ipython#1339: Notebook printing broken. Fixes ipython#1348: `Ctrl-m-Ctrl-m` does not switch to markdown cell Fixes ipython#1359: [sympyprinting] MathJax can't render \root{m}{n}
I am using this branch to fix a number of bugs in the notebook. This branch is not done yet, but the changes are significant so testing should begin now.
Addresses: #1344, #1337, #1339, #1348, #1359