[Numpy-discussion] 0/0 == 0?

Charles R Harris charlesr.harris at gmail.com
Fri Oct 3 18:55:12 EDT 2014


On Fri, Oct 3, 2014 at 3:40 PM, Nathaniel Smith <njs at pobox.com> wrote:

> On Fri, Oct 3, 2014 at 10:00 PM, Nathaniel Smith <njs at pobox.com> wrote:
> > On Fri, Oct 3, 2014 at 5:13 AM, Charles R Harris
> > <charlesr.harris at gmail.com> wrote:
> >>
> >> On Thu, Oct 2, 2014 at 10:12 PM, Charles R Harris
> >> <charlesr.harris at gmail.com> wrote:
> >> Plus the g*dawful warning default to only warn once. That has always
> >> bothered me, it just seems useless.
> >
> > I believe the idea is to only warn once per source location, i.e. if
> > you write something like:
> >
> > z = np.zeros(())
> > for foo in range(1000):
> >    z / z
> > z / z
> >
> > then you're supposed to get two warnings, for the two lines that
> > contain divide-by-zero.
> >
> > And then there is an unfortunate interaction where all lines entered
> > interactively are considered to be "the same line" for these purposes.
> >
> > I don't know why this happens. It's either a bug in ipython or in
> > warnings. The weird thing is that ipython does give each line its own
> > unique name (you can see 'filenames' like
> > "<ipython-input-4-f23c7d6238bf>" in error tracebacks), but somehow the
> > warning machinery doesn't pick up on this.
>
> Here's the solution:
>    https://github.com/ipython/ipython/issues/6611
>
>
IPython isn't involved, it's a script. The problem is that the error occurs
in the function, and when/if the same error occurs in the function,
regardless of where the function is called from, it won't be reported. It
wouldn't be so bad if the error was traced to the first rather than last
entry on the call stack.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20141003/d70283d3/attachment.html>


More information about the NumPy-Discussion mailing list