![](https://secure.gravatar.com/avatar/96dd777e397ab128fedab46af97a3a4a.jpg?s=120&d=mm&r=g)
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