[Numpy-discussion] ANN: NumPy 1.7.0b2 release

Sebastian Berg sebastian@sipsolutions....
Mon Oct 1 12:22:29 CDT 2012


On Mon, 2012-10-01 at 10:59 -0600, Charles R Harris wrote:
> 
> 
> 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.
> 
Yes, it fixes that too of course, just noted it because then it may be
obvious why to change the code there for you guys knowing numpy well :).
I will do a PR, then can see if this is the best fix.

> Chuck
> 
> 
> 
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion




More information about the NumPy-Discussion mailing list