IPython (new) + matplotlib report: happy news

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

···

On Tue, Sep 14, 2010 at 6:01 PM, Benjamin Root <ben.root@...553...> 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

···

On Wed, Sep 15, 2010 at 1:08 AM, Fernando Perez <fperez.net@gmail.com> wrote:

On Tue, Sep 14, 2010 at 6:01 PM, Benjamin Root <ben.root@…553…> wrote:

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

···

On Wed, Sep 15, 2010 at 1:10 AM, Robert Kern <robert.kern@…552…149…> 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.root@...553... > >     <mailto:ben.root@...553...>> 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.

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 :slight_smile:

Cheers,

f

···

On Tue, Sep 14, 2010 at 6:29 PM, Benjamin Root <ben.root@...553...> wrote:

Good point. I guess I am just a little *too* terminal-oriented.

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

···

On Tue, Sep 14, 2010 at 8:21 AM, John Hunter <jdh2358@...149...> 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.

That’s very cool.

Unrelated to %loadpy, but is anyone else bothered/confused by the fact that the both the plot in the website and the plot embedded in the app are wrong? There are lines that should be blue (they don’t intersect the bbox) in both that are red. I presume this is a bug in either the intersect calculation, or the plot command in the example code.

-MinRK

···

On Thu, Sep 16, 2010 at 13:36, Fernando Perez <fperez.net@gmail.com> wrote:

On Tue, Sep 14, 2010 at 8:21 AM, John Hunter <jdh2358@…716…> 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


IPython-dev mailing list

IPython-dev@…336…

http://mail.scipy.org/mailman/listinfo/ipython-dev