[Numpy-discussion] Possible bug in scalar * array

Todd Miller jmiller at stsci.edu
Mon Oct 20 12:41:14 CDT 2003


I tracked down the problem to some (relatively) new overflow checking
code which detects the overflow of the scalar -1 as it is assigned to an
array pseudo buffer of type UInt8.  This error was mishandled, and hence
was transformed into an invalid shape tuple (you gotta smile :-)).  The
*2nd* call is where the exception shows up because of caching logic.

I talked this over with Perry and we concluded that it's probably a good
thing to trap the out of range scalar values before using them.  Thus,
we're proposing to fix the error handling,  but to make the calls in
question raise an overflow exception on the first call.  We are
interested in hearing other opinions however.  Comments?

Regards,
Todd

On Sat, 2003-10-18 at 18:18, Edward C. Jones wrote:
> #! /usr/bin/env python
> 
> # Python 2.3.2, numarray 0.7
> import numarray
> 
> def fun2(code, scale):
>      arr = numarray.ones((4,4), code)
>      arr2 = scale * arr
>      # Bug appears at second multiply.
>      arr3 = scale * arr
> 
> # These calls fail when "scale" is too big for "code":
> 
> #   File 
> "/usr/local/lib/python2.3/site-packages/numarray/numarraycore.py", line 
> 653, in __rmul__
> #    def __rmul__(self, operand): return ufunc.multiply(operand, self)
> # ValueError: invalid shape tuple
> 
> #fun2('Int16', 100000)
> fun2('UInt8' , -1)
> 
> 
> 
> -------------------------------------------------------
> This SF.net email sponsored by: Enterprise Linux Forum Conference & Expo
> The Event For Linux Datacenter Solutions & Strategies in The Enterprise 
> Linux in the Boardroom; in the Front Office; & in the Server Room 
> http://www.enterpriselinuxforum.com
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion
-- 
Todd Miller 			
Space Telescope Science Institute
3700 San Martin Drive
Baltimore MD, 21030
(410) 338 - 4576





More information about the Numpy-discussion mailing list