From: Fernando P. <fpe...@gm...> - 2010-09-13 20:58:39
|
Hi folks, [ sorry for the cross-post, but devs on both lists will care about this] I just went through the exercise of pasting 100 randomly chosen examples from the gallery into the new ipython console with inline graphics. Report: - 98 worked perfectly: the figures I got were identical to those on the website. - 1 had minor visual differences: http://matplotlib.sourceforge.net/examples/pylab_examples/quadmesh_demo.html: in the SVG render, the masked region appears black instead of transparent. - One produced an error: http://matplotlib.sourceforge.net/examples/axes_grid/simple_axisline4.html ... ...: plt.draw() ...: plt.show() ...: Received invalid plot data. But when I save the file and try to load it into firefox, it seems to indeed be bad SVG: XML Parsing Error: mismatched tag. Expected: </g>. Location: file:///home/fperez/ipython/ipython/bad.svg Line Number 287, Column 3:</svg> --^ In summary: we can run pretty much any MPL example by straight copy/paste, and the only two glitches I see are in the SVG data itself. Once the other two buglets I reported earlier get fixed up, this will be a very nice way to interact with MPL. One small request: is it possible/easy to add to the MPL examples a little 'copy to clipboard' button or link? Now that one can copy/paste wholesale examples into an interactive session to explore them, it feels annoying to have to highlight the whole text box and then do Ctrl-C or menu->copy. It would be really nice to have a one-click 'copy to clipboard'... But I have no idea if that's easy or hard in HTML... Anyway, I think we're starting to be in pretty good shape! Cheers, f |
From: Brian G. <ell...@gm...> - 2010-09-13 21:10:31
|
Fernando, On Mon, Sep 13, 2010 at 1:58 PM, Fernando Perez <fpe...@gm...> wrote: > Hi folks, > > [ sorry for the cross-post, but devs on both lists will care about this] > > I just went through the exercise of pasting 100 randomly chosen > examples from the gallery into the new ipython console with inline > graphics. Report: > > - 98 worked perfectly: the figures I got were identical to those on the website. That is a pretty significant test of the new console....100 is a lot of copying and pasting. > - 1 had minor visual differences: > http://matplotlib.sourceforge.net/examples/pylab_examples/quadmesh_demo.html: > in the SVG render, the masked region > appears black instead of transparent. > > - One produced an error: > http://matplotlib.sourceforge.net/examples/axes_grid/simple_axisline4.html > > ... > ...: plt.draw() > ...: plt.show() > ...: > Received invalid plot data. > > But when I save the file and try to load it into firefox, it seems to > indeed be bad SVG: > > XML Parsing Error: mismatched tag. Expected: </g>. > Location: file:///home/fperez/ipython/ipython/bad.svg > Line Number 287, Column 3:</svg> > --^ > > In summary: we can run pretty much any MPL example by straight > copy/paste, and the only two glitches I see are in the SVG data > itself. Once the other two buglets I reported earlier get fixed up, > this will be a very nice way to interact with MPL. > > One small request: is it possible/easy to add to the MPL examples a > little 'copy to clipboard' button or link? Now that one can > copy/paste wholesale examples into an interactive session to explore > them, it feels annoying to have to highlight the whole text box and > then do Ctrl-C or menu->copy. It would be really nice to have a > one-click 'copy to clipboard'... But I have no idea if that's easy or > hard in HTML... +1 to this! Cheers, Brian > Anyway, I think we're starting to be in pretty good shape! > > Cheers, > > f > _______________________________________________ > IPython-dev mailing list > IPy...@sc... > http://mail.scipy.org/mailman/listinfo/ipython-dev > -- Brian E. Granger, Ph.D. Assistant Professor of Physics Cal Poly State University, San Luis Obispo bgr...@ca... ell...@gm... |
From: Gökhan S. <gok...@gm...> - 2010-09-13 21:22:31
|
Hi Fernando, On Mon, Sep 13, 2010 at 3:58 PM, Fernando Perez <fpe...@gm...>wrote: > Hi folks, > > One small request: is it possible/easy to add to the MPL examples a > little 'copy to clipboard' button or link? Now that one can > copy/paste wholesale examples into an interactive session to explore > them, it feels annoying to have to highlight the whole text box and > then do Ctrl-C or menu->copy. It would be really nice to have a > one-click 'copy to clipboard'... But I have no idea if that's easy or > hard in HTML... > Either in Firefox or Chrome you could use extensions [Auto Copy] to copy text selections into clipboard. -- Gökhan |
From: Fernando P. <fpe...@gm...> - 2010-09-13 23:44:26
|
On Mon, Sep 13, 2010 at 2:22 PM, Gökhan Sever <gok...@gm...> wrote: > > Either in Firefox or Chrome you could use extensions [Auto Copy] to copy > text selections into clipboard. Thanks, that's good to know. But I'm mostly thinking of teaching situations, so it would be nice to have this in the source: it's not for my use but for the benefit of students who may be in a lab where they can't install extensions. But I don't know if that can even be done in html in the first place. Cheers, f |
From: Benjamin R. <ben...@ou...> - 2010-09-14 01:03:23
|
On Mon, Sep 13, 2010 at 6:44 PM, Fernando Perez <fpe...@gm...>wrote: > On Mon, Sep 13, 2010 at 2:22 PM, Gökhan Sever <gok...@gm...> > wrote: > > > > Either in Firefox or Chrome you could use extensions [Auto Copy] to copy > > text selections into clipboard. > > Thanks, that's good to know. But I'm mostly thinking of teaching > situations, so it would be nice to have this in the source: it's not > for my use but for the benefit of students who may be in a lab where > they can't install extensions. But I don't know if that can even be > done in html in the first place. > > Cheers, > > f > In github, there is something like this for copying the address of someone's git repo, but it might be done using Flash, I am not sure. Ben Root |
From: Gökhan S. <gok...@gm...> - 2010-09-14 15:08:18
|
On Mon, Sep 13, 2010 at 6:44 PM, Fernando Perez <fpe...@gm...>wrote: > Thanks, that's good to know. But I'm mostly thinking of teaching > situations, so it would be nice to have this in the source: it's not > for my use but for the benefit of students who may be in a lab where > they can't install extensions. But I don't know if that can even be > done in html in the first place. > I think there might be a couple different approaches that might be useful for educational purposes of IPython + matplotlib usage. For instance: 1-) When one downloads a script from the matplotlib gallery via an external script (name it load_into_ipython or open_with_ipython) the contents of that gallery script (or any python script) can be executed locally inside an ipython session. 2-) Matplotlib gallery might turn to an interactive environment where you can execute the script from right within your browser and change parameters in the same browser window. As far as I know mpl figures can now be drawn on html canvas. This might for sure boost the number of matplotlib audience. -- Gökhan |
From: John H. <jd...@gm...> - 2010-09-14 15:21:53
|
On Mon, Sep 13, 2010 at 4:10 PM, Brian Granger <ell...@gm...> wrote: >> One small request: is it possible/easy to add to the MPL examples a >> little 'copy to clipboard' button or link? Now that one can >> copy/paste wholesale examples into an interactive session to explore >> them, it feels annoying to have to highlight the whole text box and >> then do Ctrl-C or menu->copy. It would be really nice to have a >> one-click 'copy to clipboard'... But I have no idea if that's easy or >> hard in HTML... > > +1 to this! On a quick googling, there are some IE only Javascript examples to do this. Apparently you can enable them in firefox but it requires a significant amount of about:config hackery (http://www.febooti.com/support/website-help/website-javascript-copy-clipboard.html). How about this as an alternative: on my box, I can drag the "source code" link from the browser into my terminal, which by default pastes the URL of the referenced *.py into the terminal. If "run" supported a -w (web) option, or automatically detected that the URL starts with http, it could do a web run of the file. Of course, you may want the source code pasted in for illustrative purposes... To support this, you could add a -u (url) option to "paste" which assumes the input is a url, fetches it, and pastes the contents into ipython. So you could type "paste -u" and then drag the link into the terminal, and it would fetch it and paste the code into an input block. JDH |
From: Fernando P. <fpe...@gm...> - 2010-09-14 18:21:19
|
Hey, On Tue, Sep 14, 2010 at 8:21 AM, John Hunter <jd...@gm...> wrote: > > How about this as an alternative: on my box, I can drag the "source > code" link from the browser into my terminal, which by default pastes > the URL of the referenced *.py into the terminal. If "run" supported > a -w (web) option, or automatically detected that the URL starts with > http, it could do a web run of the file. Of course, you may want the > source code pasted in for illustrative purposes... To support this, > you could add a -u (url) option to "paste" which assumes the input is > a url, fetches it, and pastes the contents into ipython. So you could > type "paste -u" and then drag the link into the terminal, and it would > fetch it and paste the code into an input block. I'll play with those ideas, good thoughts. %paste may not be the best location because paste is now a terminal-only magic, since gui clients have 'real' paste. What's a little trickier now is that we really need to think all the time in terms of completely separate kernel and client codes, that only communicate via messages. So a magic can't muck with code in the client, because the magic executes inside the kernel and the client is in a separate process (and possibly in a separate computer). While this is a bit more constraining, it forces us to have a clean separation between different kinds of functionality. We've toyed with the idea of enabling a special syntax for *purely client side* commands, something like :cmd that would never be sent to the kernel, and would be something for the client to process internally. But we'll have to mull this a little longer... One very important point in all of this is that the client *may not be written in Python*. All we have is a messaging protocol, the client could be a web browser or anything else. But in any case, I'll play with ways to expose this that are as easy as possible for the users thanks for the feedback. Cheers, f |
From: Michael D. <md...@st...> - 2010-09-14 16:00:08
|
On 09/13/2010 04:58 PM, Fernando Perez wrote: > Hi folks, > > [ sorry for the cross-post, but devs on both lists will care about this] > > I just went through the exercise of pasting 100 randomly chosen > examples from the gallery into the new ipython console with inline > graphics. Report: > > - 98 worked perfectly: the figures I got were identical to those on the website. > > - 1 had minor visual differences: > http://matplotlib.sourceforge.net/examples/pylab_examples/quadmesh_demo.html: > in the SVG render, the masked region > appears black instead of transparent. > This is now fixed in r8699. > - One produced an error: > http://matplotlib.sourceforge.net/examples/axes_grid/simple_axisline4.html > > ... > ...: plt.draw() > ...: plt.show() > ...: > Received invalid plot data. > This is now fixed in r8700. > But when I save the file and try to load it into firefox, it seems to > indeed be bad SVG: > > XML Parsing Error: mismatched tag. Expected:</g>. > Location: file:///home/fperez/ipython/ipython/bad.svg > Line Number 287, Column 3:</svg> > --^ > > In summary: we can run pretty much any MPL example by straight > copy/paste, and the only two glitches I see are in the SVG data > itself. Once the other two buglets I reported earlier get fixed up, > this will be a very nice way to interact with MPL. > > One small request: is it possible/easy to add to the MPL examples a > little 'copy to clipboard' button or link? Now that one can > copy/paste wholesale examples into an interactive session to explore > them, it feels annoying to have to highlight the whole text box and > then do Ctrl-C or menu->copy. It would be really nice to have a > one-click 'copy to clipboard'... But I have no idea if that's easy or > hard in HTML... > Good idea. I'll have a look at how hard this would be to add as a Sphinx extension. Cheers, Mike > Anyway, I think we're starting to be in pretty good shape! > > Cheers, > > f > > ------------------------------------------------------------------------------ > Start uncovering the many advantages of virtual appliances > and start using them to simplify application deployment and > accelerate your shift to cloud computing > http://p.sf.net/sfu/novell-sfdev2dev > _______________________________________________ > Matplotlib-devel mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-devel > -- Michael Droettboom Science Software Branch Space Telescope Science Institute Baltimore, Maryland, USA |
From: Fernando P. <fpe...@gm...> - 2010-09-14 18:13:17
|
On Tue, Sep 14, 2010 at 8:59 AM, Michael Droettboom <md...@st...> wrote: > > This is now fixed in r8699. >> - One produced an error: >> http://matplotlib.sourceforge.net/examples/axes_grid/simple_axisline4.html >> >> ... >> ...: plt.draw() >> ...: plt.show() >> ...: >> Received invalid plot data. >> > This is now fixed in r8700. Great, many thanks for these fixes! It means that we're probably capable now of running just about every pylab example out of the box... We'll keep testing and will report if we see anything weird. >> One small request: is it possible/easy to add to the MPL examples a >> little 'copy to clipboard' button or link? Now that one can >> copy/paste wholesale examples into an interactive session to explore >> them, it feels annoying to have to highlight the whole text box and >> then do Ctrl-C or menu->copy. It would be really nice to have a >> one-click 'copy to clipboard'... But I have no idea if that's easy or >> hard in HTML... >> > Good idea. I'll have a look at how hard this would be to add as a > Sphinx extension. Great, if it can be done it would be wonderful (Robert indicated it may require flash, but others provided JS pointers; I'll leave it to you to navigate those lovely waters :) Cheers, f |
From: David Warde-F. <war...@ir...> - 2010-09-14 02:42:00
|
On 2010-09-13, at 7:44 PM, Fernando Perez wrote: > Thanks, that's good to know. But I'm mostly thinking of teaching > situations, so it would be nice to have this in the source: it's not > for my use but for the benefit of students who may be in a lab where > they can't install extensions. But I don't know if that can even be > done in html in the first place. You can definitely hijack copies with JavaScript: http://stackoverflow.com/questions/400212/how-to-copy-to-clipboard-in-javascript Nice work IPython people! I haven't been following too closely but this looks exciting. David |
From: Fernando P. <fpe...@gm...> - 2010-09-14 18:14:58
|
On Mon, Sep 13, 2010 at 7:08 PM, David Warde-Farley <war...@ir...> wrote: > > Nice work IPython people! I haven't been following too closely but this looks exciting. Thanks, David. Hopefully by next week we'll complete our stabilization so that we're willing to foist this on the ipython-dev and mpl-dev denizens. Anyone is welcome to try it out now, but we're moving things around enough that at any given point it may or may not work. We'll move it into trunk once the churn stops. Regards, f |
From: Anne A. <aar...@ph...> - 2010-09-14 18:48:51
|
On 14 September 2010 11:08, Gökhan Sever <gok...@gm...> wrote: > 1-) When one downloads a script from the matplotlib gallery via an external > script (name it load_into_ipython or open_with_ipython) the contents of that > gallery script (or any python script) can be executed locally inside an > ipython session. Not to be difficult, but I should point out that allowing users to run code with one click, particularly if that code is from a wiki or other user-submitted gallery, is just asking for trouble. How long before someone submits "import os, shutil; shutil.deltree(os.environ['HOME'])"? Or sneaks it into some otherwise inoffensive script? > 2-) Matplotlib gallery might turn to an interactive environment where you > can execute the script from right within your browser and change parameters > in the same browser window. As far as I know mpl figures can now be drawn on > html canvas. This might for sure boost the number of matplotlib audience. Is there a sandboxed browser plugin? Or server plugin, depending on where you run the script? Anne |
From: Gökhan S. <gok...@gm...> - 2010-09-14 19:23:11
|
On Tue, Sep 14, 2010 at 1:48 PM, Anne Archibald <aar...@ph...>wrote: > On 14 September 2010 11:08, Gökhan Sever <gok...@gm...> wrote: > > > 1-) When one downloads a script from the matplotlib gallery via an > external > > script (name it load_into_ipython or open_with_ipython) the contents of > that > > gallery script (or any python script) can be executed locally inside an > > ipython session. > > Not to be difficult, but I should point out that allowing users to run > code with one click, particularly if that code is from a wiki or other > user-submitted gallery, is just asking for trouble. How long before > someone submits "import os, shutil; > shutil.deltree(os.environ['HOME'])"? Or sneaks it into some otherwise > inoffensive script? > I was thinking naively --with Python for Science in mind not Python for Hacking. I accept this is a not good idea considering that harmful effect but in this brave new world of us there is always danger involved when one puts their hands on virtual lands --whether the code is executed intentionally or sneaked by a conic head. > > > 2-) Matplotlib gallery might turn to an interactive environment where you > > can execute the script from right within your browser and change > parameters > > in the same browser window. As far as I know mpl figures can now be drawn > on > > html canvas. This might for sure boost the number of matplotlib audience. > > Is there a sandboxed browser plugin? Or server plugin, depending on > where you run the script? > This one is one of my aloud speculations. Only at ideas level. I will write more, answering Fernando's reply. > > Anne > -- Gökhan |
From: Fernando P. <fpe...@gm...> - 2010-09-14 18:58:40
|
On Tue, Sep 14, 2010 at 11:48 AM, Anne Archibald <aar...@ph...> wrote: > On 14 September 2010 11:08, Gökhan Sever <gok...@gm...> wrote: > >> 1-) When one downloads a script from the matplotlib gallery via an external >> script (name it load_into_ipython or open_with_ipython) the contents of that >> gallery script (or any python script) can be executed locally inside an >> ipython session. > > Not to be difficult, but I should point out that allowing users to run > code with one click, particularly if that code is from a wiki or other > user-submitted gallery, is just asking for trouble. How long before > someone submits "import os, shutil; > shutil.deltree(os.environ['HOME'])"? Or sneaks it into some otherwise > inoffensive script? Very valid points. I'm leaning more towards something like a combination of (hopefully) a 'copy code' button on the MPL webpages themselves, so users don't have to scroll/highlight a lot but would still do paste, execute manually, and a special %mplexample magic. This would only run examples from the mpl gallery (hardcoding the path), would display the code to the user first, and would ask for confirmation before execution. Since those html pages are built by executing those same scripts, there's a layer of sanity already built into it (the rmtree call would have already nuked the builder's home directory in the build process if it had been there). Showing the code to the user and confirming execution before proceeding adds a final chance for the person to check her parachute before jumping off the cliff. Does that sound reasonable? >> 2-) Matplotlib gallery might turn to an interactive environment where you >> can execute the script from right within your browser and change parameters >> in the same browser window. As far as I know mpl figures can now be drawn on >> html canvas. This might for sure boost the number of matplotlib audience. > > Is there a sandboxed browser plugin? Or server plugin, depending on > where you run the script? This would have to be server-side, and code needs to be written. Part of our interest with this explicit separation of ipython kernel and clients with a well-defined protocol is to make the above possible. But we haven't written any of the code necessary to have a browser client, and to serve code read from a sphinx-generated HTML page. Gokhan, your patches will be welcome, the infrastructure is now ready and waiting for you :) Cheers, f |
From: Gökhan S. <gok...@gm...> - 2010-09-14 19:39:04
|
On Tue, Sep 14, 2010 at 1:58 PM, Fernando Perez <fpe...@gm...>wrote: > >> 2-) Matplotlib gallery might turn to an interactive environment where > you > >> can execute the script from right within your browser and change > parameters > >> in the same browser window. As far as I know mpl figures can now be > drawn on > >> html canvas. This might for sure boost the number of matplotlib > audience. > > > > Is there a sandboxed browser plugin? Or server plugin, depending on > > where you run the script? > > This would have to be server-side, and code needs to be written. Part > of our interest with this explicit separation of ipython kernel and > clients with a well-defined protocol is to make the above possible. > But we haven't written any of the code necessary to have a browser > client, and to serve code read from a sphinx-generated HTML page. > Gokhan, your patches will be welcome, the infrastructure is now ready > and waiting for you :) Sage provides some level of interaction actually without any deployment made on local side. Try for instance the following example on sagenb.org from scipy import stats import numpy as np import matplotlib.pyplot as plt @interact def plot_gamma(a=(1,(1,10)), loc=(0,(0,10)), scale=(1,(1,10))): rv = stats.gamma(a, loc, scale) x = np.linspace(-1,20,1000) plt.plot(x,rv.pdf(x)) plt.grid(True) plt.savefig('plt.png') plt.clf() This one is very useful for educational and demonstrative purposes. Still requires a bit Sage syntax manipulations to make things fully interacting on browser. Nice that you have matured IPython infra for implementing such interactive functionality. I was thinking perhaps running something on top GApss Engine but not sure they allow compiling/running C/C++ extensions on their servers. Alternatively, like in Sage servers virtual OS'es might be the way to go with it then possibly there will be user registration and management issues (not sure about all specifics). Probably, Ondrej might like experiencing with this idea :) Since he has similar initiatives and asking help on similar topics. I am trying to graduate myself working to solve some of my research problems and struggling with writing especially to move on PhD. This might be a very fun Summer job if I am wandering around jobless then. -- Gökhan |
From: Fernando P. <fpe...@gm...> - 2010-09-14 19:50:16
|
On Tue, Sep 14, 2010 at 12:38 PM, Gökhan Sever <gok...@gm...> wrote: > > Sage provides some level of interaction actually without any deployment made > on local side. Try for instance the following example on sagenb.org > from scipy import stats > import numpy as np > import matplotlib.pyplot as plt > @interact > def plot_gamma(a=(1,(1,10)), loc=(0,(0,10)), scale=(1,(1,10))): > rv = stats.gamma(a, loc, scale) > x = np.linspace(-1,20,1000) > plt.plot(x,rv.pdf(x)) > plt.grid(True) > plt.savefig('plt.png') > plt.clf() > This one is very useful for educational and demonstrative purposes. Still > requires a bit Sage syntax manipulations to make things fully interacting on > browser. > Nice that you have matured IPython infra for implementing > such interactive functionality. I was thinking perhaps running something on > top GApss Engine but not sure they allow compiling/running C/C++ extensions > on their servers. Alternatively, like in Sage servers virtual OS'es might be > the way to go with it then possibly there will be user registration and > management issues (not sure about all specifics). Actually sage does have one *implicit* but very particular 'local deployment': its notebook execution model is *strictly* tied to the idea that the client is a web browser. Try this code in the sage terminal (i.e. their customized ipython, not the notebook): sage: @interact ....: def x(a=(1, (1, 10))): ....: print a ....: and you'll see: <html><!--notruncate--><div padding=6 id='div-interact-0'> <table width=800px height=20px bgcolor='#c5c5c5' cellpadding=15><tr><td bgcolor='#f9f9f9' valign=top align=left><table><tr><td align=right><font color="black">a </font></td><td><table><tr><td> <div id='slider-a-0' style='margin:0px; margin-left: 1.0em; margin-right: 1.0em; width: 15.0em;'></div> ... lots more... </table><div id='cell-interact-0'><?__SAGE__START> <table border=0 bgcolor='#white' width=100% height=100%> <tr><td bgcolor=white align=left valign=top><pre><?__SAGE__TEXT></pre></td></tr> <tr><td align=left valign=top><?__SAGE__HTML></td></tr> </table><?__SAGE__END></div></td> </tr></table></div> </html> sage: So you can see, @interact in sage does basically: - analyze the inputs of the function - do some basic 'type inference' and emit javascript/html controls for each parameter. - emit an html section that wires the above controls to repeated calls of the decorated function as the controls are operated. This is very cool, and it enables great functionality, but it's hard-coded to an html/javascript client. What we're doing is a little different, as we've built a *protocol* that clients can use to talk to the kernel, regardless of how they are implemented. As the functionality matures, we'll see who contributes a browser-based client (that will require wrapping the kernel in an http server, obviously). And then the question of things like @interact will be an interesting one to think about. @interact by nature is creating a user interface (Mathematica's Manipulate creates Notebook controls, sage's @interact creates HTML ones). I'm not sure yet how we'll approach that: having per-client implementations? A traits-style approach where each client renders it differently? No idea yet. Cheers, f |
From: Benjamin R. <ben...@ou...> - 2010-09-14 19:57:53
|
On Tue, Sep 14, 2010 at 1:58 PM, Fernando Perez <fpe...@gm...>wrote: > On Tue, Sep 14, 2010 at 11:48 AM, Anne Archibald > <aar...@ph...> wrote: > > On 14 September 2010 11:08, Gökhan Sever <gok...@gm...> wrote: > > > >> 1-) When one downloads a script from the matplotlib gallery via an > external > >> script (name it load_into_ipython or open_with_ipython) the contents of > that > >> gallery script (or any python script) can be executed locally inside an > >> ipython session. > > > > Not to be difficult, but I should point out that allowing users to run > > code with one click, particularly if that code is from a wiki or other > > user-submitted gallery, is just asking for trouble. How long before > > someone submits "import os, shutil; > > shutil.deltree(os.environ['HOME'])"? Or sneaks it into some otherwise > > inoffensive script? > > Very valid points. I'm leaning more towards something like a > combination of (hopefully) a 'copy code' button on the MPL webpages > themselves, so users don't have to scroll/highlight a lot but would > still do paste, execute manually, and a special %mplexample magic. > > This would only run examples from the mpl gallery (hardcoding the > path), would display the code to the user first, and would ask for > confirmation before execution. Since those html pages are built by > executing those same scripts, there's a layer of sanity already built > into it (the rmtree call would have already nuked the builder's home > directory in the build process if it had been there). Showing the > code to the user and confirming execution before proceeding adds a > final chance for the person to check her parachute before jumping off > the cliff. > > Does that sound reasonable? > > >> 2-) Matplotlib gallery might turn to an interactive environment where > you > >> can execute the script from right within your browser and change > parameters > >> in the same browser window. As far as I know mpl figures can now be > drawn on > >> html canvas. This might for sure boost the number of matplotlib > audience. > > > > Is there a sandboxed browser plugin? Or server plugin, depending on > > where you run the script? > > This would have to be server-side, and code needs to be written. Part > of our interest with this explicit separation of ipython kernel and > clients with a well-defined protocol is to make the above possible. > But we haven't written any of the code necessary to have a browser > client, and to serve code read from a sphinx-generated HTML page. > Gokhan, your patches will be welcome, the infrastructure is now ready > and waiting for you :) > > Cheers, > > f > Just a crazy idea to consider that would completely bypass this whole vulnerability issue... Why not have an examples module that contains function calls to each example? On the website, we can show the source code, but also say that one could just do: >>> import matplotlib.examples as ex >>> ex.bars3d_demo() My 2 cents... Ben Root |
From: Fernando P. <fpe...@gm...> - 2010-09-15 00:39:40
|
On Tue, Sep 14, 2010 at 12:57 PM, Benjamin Root <ben...@ou...> wrote: > > Why not have an examples module that contains function calls to each > example? On the website, we can show the source code, but also say that one > could just do: > >>>> import matplotlib.examples as ex >>>> ex.bars3d_demo() The idea is to have the *actual code* pasted in your terminal, because now we can easily edit complex multi-line examples directly in ipython. So it's not just a matter of seeing the figure results, but mostly of having the actual source in your input buffer to play with. Cheers, f |
From: Benjamin R. <ben...@ou...> - 2010-09-15 01:02:24
|
On Wed, Sep 15, 2010 at 12:39 AM, Fernando Perez <fpe...@gm...>wrote: > On Tue, Sep 14, 2010 at 12:57 PM, Benjamin Root <ben...@ou...> wrote: > > > > Why not have an examples module that contains function calls to each > > example? On the website, we can show the source code, but also say that > one > > could just do: > > > >>>> import matplotlib.examples as ex > >>>> ex.bars3d_demo() > > The idea is to have the *actual code* pasted in your terminal, because > now we can easily edit complex multi-line examples directly in > ipython. So it's not just a matter of seeing the figure results, but > mostly of having the actual source in your input buffer to play with. > > Cheers, > > f > True... but, consider this. ipython can already display the code for a particular module/function using the '??' idiom. Why not have some way to take that text and bring it into the input buffer? I can imagine this being useful beyond matplotlib where anybody could have their example codes easily accessed and edited. Ben Root |
From: Fernando P. <fpe...@gm...> - 2010-09-15 01:09:18
|
On Tue, Sep 14, 2010 at 6:01 PM, Benjamin Root <ben...@ou...> wrote: > True... but, consider this. ipython can already display the code for a > particular module/function using the '??' idiom. Why not have some way to > take that text and bring it into the input buffer? Yes, but that's a separate issue. The approach you propose would likely have in ex.demo_somehting() a stub to retrieve the actual example code as a string from a file elsewhere, because (at least right now) the mpl examples are written as 100% standalone files, not as functions inside of some other control module. What you are saying does apply to the mayavi.mlab.test_*() functions, that do serve as examples precisely in that manner, since those *do* contain their code inside the functions. So for the matplotlib examples, that live in standalone files, we'd still need something different. > I can imagine this being useful beyond matplotlib where anybody could have > their example codes easily accessed and edited. Certainly! Right now the pager is a very simple tool, but I hope that once we put this code out we'll get contributions from enterprising Qt coders who may improve it and add things like a button that would copy the code from the source part of an info pane and paste it in the interactive area, all with a single click. We want to settle the core protocol/messaging behavior first, and once this is ready and people test it a little, I really hope we'll get contributions that enhance the user experience very much in this manner. Cheers, f |
From: Benjamin R. <ben...@ou...> - 2010-09-15 01:23:26
|
On Wed, Sep 15, 2010 at 1:08 AM, Fernando Perez <fpe...@gm...>wrote: > On Tue, Sep 14, 2010 at 6:01 PM, Benjamin Root <ben...@ou...> wrote: > > True... but, consider this. ipython can already display the code for a > > particular module/function using the '??' idiom. Why not have some way > to > > take that text and bring it into the input buffer? > > Yes, but that's a separate issue. The approach you propose would > likely have in ex.demo_somehting() a stub to retrieve the actual > example code as a string from a file elsewhere, because (at least > right now) the mpl examples are written as 100% standalone files, not > as functions inside of some other control module. What you are saying > does apply to the mayavi.mlab.test_*() functions, that do serve as > examples precisely in that manner, since those *do* contain their code > inside the functions. > > So for the matplotlib examples, that live in standalone files, we'd > still need something different. > > Well, my idea was predicated upon what I said previously that matplotlib should package the examples into a useful module with function call. This way, one could have been able to run the demos and view the code just like any other piece of code in matplotlib. > > I can imagine this being useful beyond matplotlib where anybody could > have > > their example codes easily accessed and edited. > > Certainly! Right now the pager is a very simple tool, but I hope that > once we put this code out we'll get contributions from enterprising Qt > coders who may improve it and add things like a button that would copy > the code from the source part of an info pane and paste it in the > interactive area, all with a single click. > > We want to settle the core protocol/messaging behavior first, and once > this is ready and people test it a little, I really hope we'll get > contributions that enhance the user experience very much in this > manner. > > That is a good gameplan. What I have seen of ipython is very good and really resolves a lot of gripes I have had with my typical python development workflow. Keep up the good work! Ben Root |
From: Benjamin R. <ben...@ou...> - 2010-09-15 01:29:46
|
On Wed, Sep 15, 2010 at 1:10 AM, Robert Kern <rob...@gm...> wrote: > On 9/14/10 8:01 PM, Benjamin Root wrote: > > On Wed, Sep 15, 2010 at 12:39 AM, Fernando Perez <fperez.net > > <http://fperez.net>@gmail.com <http://gmail.com>> wrote: > > > > On Tue, Sep 14, 2010 at 12:57 PM, Benjamin Root <ben...@ou... > > <mailto:ben...@ou...>> wrote: > > > > > > Why not have an examples module that contains function calls to > each > > > example? On the website, we can show the source code, but also > say that one > > > could just do: > > > > > >>>> import matplotlib.examples as ex > > >>>> ex.bars3d_demo() > > > > The idea is to have the *actual code* pasted in your terminal, > because > > now we can easily edit complex multi-line examples directly in > > ipython. So it's not just a matter of seeing the figure results, but > > mostly of having the actual source in your input buffer to play with. > > > > Cheers, > > > > f > > > > > > True... but, consider this. ipython can already display the code for a > > particular module/function using the '??' idiom. Why not have some way > to take > > that text and bring it into the input buffer? > > Regardless of whether or not this is a good idea, it doesn't replace the > functionality Fernando is requesting. People *will* be looking at the > matplotlib > docs on the web and copy-pasting the examples. Placing a link that they can > click to easily, robustly, and *obviously* copy the code for pasting into > the > shell (or anywhere else!) is better than telling them to go type some magic > commands they've probably never seen before. Magic commands that they will > probably want to copy-paste. And so the cycle is complete. > > Good point. I guess I am just a little *too* terminal-oriented. I tend to access the examples directly and have to copy-and-paste snippets of code, which has many issues with indentation and empty lines. Just the new input buffer of ipython is a significant enough feature to stand on its own and be beneficial. How we get text to it can be done in many different ways. Ben Root |
From: Fernando P. <fpe...@gm...> - 2010-09-15 04:18:21
|
On Tue, Sep 14, 2010 at 6:29 PM, Benjamin Root <ben...@ou...> wrote: > Good point. I guess I am just a little *too* terminal-oriented. It's probably worth mentioning that we've gone to great lengths to try to produce in the new console an experience that's as seamless and fluid as possible to anyone who 'lives in a terminal' (like myself). We want this to be 'a terminal, but better': multiline editing, inline graphics, html documentation, popups with call tips, but all the keyboard friendliness and raw efficiency of a terminal. Put another way: this should be 100% usable *without* a mouse, and you should be more efficient with this in python than with any terminal. If you're not, it's a bug :) Cheers, f |
From: Fernando P. <fpe...@gm...> - 2010-09-16 20:36:51
|
On Tue, Sep 14, 2010 at 8:21 AM, John Hunter <jd...@gm...> wrote: > > How about this as an alternative: on my box, I can drag the "source > code" link from the browser into my terminal, which by default pastes > the URL of the referenced *.py into the terminal. If "run" supported > a -w (web) option, or automatically detected that the URL starts with > http, it could do a web run of the file. Of course, you may want the > source code pasted in for illustrative purposes... To support this, > you could add a -u (url) option to "paste" which assumes the input is > a url, fetches it, and pastes the contents into ipython. So you could > type "paste -u" and then drag the link into the terminal, and it would > fetch it and paste the code into an input block. Ask and ye shall receive (yes, the url was drag-dropped from the 'source code' link in the mpl page), welcome %loadpy: http://fperez.org/tmp/iqlab_mpl_loadpy.png Full credits go to Brian and Evan! Cheers, f |