[Numpy-discussion] Bug fix or behavior change?
Charles R Harris
charlesr.harris@gmail....
Sat Sep 27 02:25:10 CDT 2008
On Sat, Sep 27, 2008 at 1:18 AM, Charles R Harris <charlesr.harris@gmail.com
> wrote:
>
>
> On Sat, Sep 27, 2008 at 12:51 AM, Travis E. Oliphant <
> oliphant@enthought.com> 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
>> > 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.
>>
>
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20080927/062a021c/attachment-0001.html
More information about the Numpy-discussion
mailing list