[Numpy-discussion] ANN: NumPy 1.7.0b2 release

Charles R Harris charlesr.harris@gmail....
Mon Oct 1 11:59:00 CDT 2012


On Mon, Oct 1, 2012 at 10:09 AM, Sebastian Berg
<sebastian@sipsolutions.net>wrote:

> Hey,
>
> About the imaginary part being ignored for all/any function...
>
> <snip>
>
>
> > The all method fails also.
> >
> > In [1]: a = zeros(5, complex)
> >
> > In [2]: a.imag = 1
> >
> > In [3]: a.all()
> > Out[3]: False
> >
> > Chuck
> >
> I believe this diff fixes the issue (also posted on Tracker), I doubt
> its the best way to fix the issue, but if anyone who knows this code
> wants to look into it its good to know what is broken. Note that also
> a.astype(bool) fails:
>
> --- a/numpy/core/src/multiarray/lowlevel_strided_loops.c.src
> +++ b/numpy/core/src/multiarray/lowlevel_strided_loops.c.src
> @@ -811,9 +811,17 @@ static void
>      dst_value[0] = _CONVERT_FN(src_value[0]);
>      dst_value[1] = _CONVERT_FN(src_value[1]);
>  #  elif !@aligned@
> -    dst_value = _CONVERT_FN(src_value[0]);
> +#    if @is_bool2@
> +       dst_value = _CONVERT_FN(src_value[0]) || _CONVERT_FN(src_value[1]);
> +#    else
> +       dst_value = _CONVERT_FN(src_value[0]);
> +#    endif
>  #  else
> -    *(_TYPE2 *)dst = _CONVERT_FN(src_value[0]);
> +#    if @is_bool2@
> +       *(_TYPE2 *)dst = _CONVERT_FN(src_value[0]) ||
> _CONVERT_FN(src_value[1]);
> +#    else
> +       *(_TYPE2 *)dst = _CONVERT_FN(src_value[0]);
> +#    endif
>  #  endif
>  #else
>  #  if @is_complex2@
>
>
>
Hey, I think you are onto something. I'm I correct in assuming the this
also fixes astype(bool)? In any case, it would be nice if you submitted
this as an ordinary PR and added some tests. That would be the fastest
route to getting it reviewed and committed.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20121001/e6e84501/attachment.html 


More information about the NumPy-Discussion mailing list