On Sat, Sep 27, 2008 at 1:18 AM, Charles R Harris <[EMAIL PROTECTED]
> wrote:

>
>
> On Sat, Sep 27, 2008 at 12:51 AM, Travis E. Oliphant <
> [EMAIL PROTECTED]> wrote:
>
>> 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
>> > [EMAIL PROTECTED]@(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.
>>
>
> Done. I've made all the boolean ufuncs convert args to  0 or 1 before
> applying the operators. Next question, what about logical_and applied to
> complex numbers. Currently it gives
>

I'm also thinking that bitwise operators should not be allowed for booleans.
But that might break some code...

Chuck
_______________________________________________
Numpy-discussion mailing list
[email protected]
http://projects.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to