[Numpy-discussion] ANN: NumPy 1.7.0b2 release

Sebastian Berg sebastian at sipsolutions.net
Mon Oct 1 12:09:55 EDT 2012


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@


Regards,

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





More information about the NumPy-Discussion mailing list