[Numpy-discussion] Bug fix or behavior change?
Travis E. Oliphant
oliphant@enthought....
Sat Sep 27 01:51:19 CDT 2008
Charles R Harris wrote:
> Hi All,
>
> Currently subtract for boolean arrays is defined in
>
> /**begin repeat
> * Arithmetic operators
> *
> * # OP = ||, ^, &&#
> * #kind = add, subtract, multiply#
> */
> static void
> BOOL_@kind@(char **args, intp *dimensions, intp *steps, void *func)
> {
> register intp i;
> intp is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];
> char *i1=args[0], *i2=args[1], *op=args[2];
> for(i=0; i<n; i++, i1+=is1, i2+=is2, op+=os) {
> *((Bool *)op)=*((Bool *)i1) @OP@ *((Bool *)i2);
> }
> }
> /**end repeat**/
>
>
> Note that this might yield unexpected results if the boolean value is
> not 0 or 1, which is possible using views. Note also that bitwise_xor
> converts the boolean to 0 or 1 before using ^. I think subtract should
> work the same way, but that would change current behavior. So... do I
> make the change and call it a bug fix or leave it as it is?
I think it's a bugfix and so am +1 on the change.
-Travis
More information about the Numpy-discussion
mailing list