[Numpy-discussion] Six-legged feature in median function

Mike Ressler mike.ressler at alum.mit.edu
Wed May 23 20:03:07 EDT 2007


Bumped into the following in numpy-1.0.2 and 1.0.3 (of course :-) on
both 32-bit and 64-bit linux boxes:

>>> import numpy as nm
>>> a=nm.zeros(1000000,dtype='Int32')-30000
>>> nm.median(a)
-30000.0
>>> a=nm.zeros(1000000,dtype='Int16')-30000
>>> nm.median(a)
Warning: overflow encountered in short_scalars
2768.0

Something in the computation of median overflows when there are a
large number of values near the ends of an Int16 (like my image data).
I can work around this, of course, by casting the data as something
larger, but this one could definitely use a tweak.

Mike

-- 
mike.ressler at alum.mit.edu



More information about the NumPy-Discussion mailing list