[Numpy-discussion] Possible bug in scalar * array
jmiller at stsci.edu
Tue Oct 21 07:34:02 EDT 2003
On Tue, 2003-10-21 at 03:53, Francesc Alted wrote:
> A Dilluns 20 Octubre 2003 21:36, Todd Miller va escriure:
> > 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?
> You mean implementing range checking in numarray objects? In my opinion,
> that would be a very nice feature, although I don't know how that would
> affect the assignment performance.
I don't anticipate any impact on performance for the limited scope we
were proposing: overflow checking for the scalar parameters of binary
ufuncs. There are other areas where overflow checking could be employed
but won't be. So, trying to create a more coherent picture,
Here is where we will check for overflows:
1. fromlist(), if you specify check_overflow=1.
2. scalar parameters of binary ufuncs. So 1+a will make sure "1" fits
in the array implied by a.type().
3. non-array-sequence parameters of binary ufuncs. So add(a,[1,2,3])
ensures that [1,2,3] can be stored in an array of the type implied by
4. The multiply ufunc.
5. a[<single_element_index>] = x whenever a._check_overflow is 1.
Here is where we won't check for overflows:
1. array(), or fromlist() by default.
2. most binary ufuncs. So a+b won't check, assuming a and b are both
3. a[<block_of_elements_index>] = b, regardless of a._check_overflow.
Comments? Anything grossly inconsistent here?
> Francesc Alted
> This SF.net email is sponsored by OSDN developer relations
> Here's your chance to show off your extensive product knowledge
> We want to know what you know. Tell us and you have a chance to win $100
> Numpy-discussion mailing list
> Numpy-discussion at lists.sourceforge.net
Space Telescope Science Institute
3700 San Martin Drive
Baltimore MD, 21030
(410) 338 - 4576
More information about the NumPy-Discussion