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

Nathaniel Smith njs at pobox.com
Fri Oct 3 17:00:05 EDT 2014

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.


Nathaniel J. Smith
Postdoctoral researcher - Informatics - University of Edinburgh

More information about the NumPy-Discussion mailing list