[Numpy-discussion] Bug fix or behavior change?

Charles R Harris charlesr.harris at gmail.com
Thu Sep 25 20:50:20 EDT 2008


Hi All,

Currently subtract for boolean arrays is defined in

/**begin repeat
 * Arithmetic operators
 *
 * # OP = ||, ^, &&#
 * #kind = add, subtract, multiply#
 */
static void
BOOL_ at 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?

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20080925/95e8a5ef/attachment.html>


More information about the NumPy-Discussion mailing list