[Numpy-discussion] numarray vs IPython
jmiller at stsci.edu
Tue Dec 7 12:41:02 EST 2004
I wanted to let you guys know that there's a "post-it note" stuck to my
monitor to remind me to look at this. A quick glance indicated that
--classic does not fix the problem... but that's all I know so far and
all I'll get to in the immediate future.
On Tue, 2004-12-07 at 14:05, Fernando Perez wrote:
> Andrea Riciputi schrieb:
> > The same here (OS X, Python 2.3.4, ipython 0.6.5). The problem is due
> > to the way in which numarray performs its tests. It relies on the
> > Python module doctest that execute the script in doc strings. I think
> > that since in numarray doc strings the expected output is written in
> > the standard Python way (i.e. >>> foo) while ipython writes out
> > something like "Out[n]: foo" the checks fail.
> Thanks for that info, this is most likely the culprit. Here's a simple test
> to confirm things: start ipython as 'ipython --classic', which disables the
> fancy prompt system and makes it produce regular python prompts. Run the
> tests there and see what happens.
> Since numarray is more and more likely to be run by ipython users, it might be
> worth adding a bit of robustness to these tests when under ipython. Here are
> some suggestions, starting with the simplest:
> 1. Run a first 'empty' test just to do prompt detection. If this one fails, do:
> except NameError:
> print 'Big time problem, not caused by ipython'
> print 'Run ipython --classic for doctests to work'
> or some fancier version of the above.
> 2. Even better, patch doctest to recognize prompts based on a regexp. The
> python-mode.el guys did this for (x)emacs support, and it now works very well
> with ipython. The python-mode CVS code can be studied for the proper regexps.
> By default this regexp can be set to recognize the normal ipython prompts.
> 3. If you do 2, and you want to get real fancy, the numarray doctest could
> build the regexp automatically, from the ipython prompt configuration strings.
> These are always available at runtime:
> In : __IPYTHON__.rc.prom
> __IPYTHON__.rc.prompt_in1 __IPYTHON__.rc.prompt_in2 __IPYTHON__.rc.prompt_out
> In : __IPYTHON__.rc.prompt_in1
> Out: 'In [\\#]:'
> In : __IPYTHON__.rc.prompt_in2
> Out: ' .\\D.:'
> In : __IPYTHON__.rc.prompt_out
> Out: 'Out[\\#]:'
> So the situation looks not too bad. There's a quick fix (--classic) for now,
> and if someone feels up to the task of patching doctest, a pretty elegant
> solution can be implemented.
> SF email is sponsored by - The IT Product Guide
> Read honest & candid reviews on hundreds of IT Products from real users.
> Discover which products truly live up to the hype. Start reading now.
> Numpy-discussion mailing list
> Numpy-discussion at lists.sourceforge.net
More information about the NumPy-Discussion