Hi again Julian,

> its not np.any that is slow in this case its np.array([A, B, C])

Not really. The 4 unique alternative implementations provided all work quickly 
and correctly as-is, without a need to jump through a strange idiomatic hoop, 
so the problem does indeed lie with the implementation approach used in the 
current numpy.any(). 

It is unreasonable to expect users to know and always prepare their data using 
the idiom you propose if they might want to use the .any() function. If quirky 
idioms are needed to fix the performance of .any(), they should be placed in 
the implementation of .any().


>  this has the same performance as your code:
> a = empty([3] list(A.shape)

How do you know? This isn't valid Python, it won't run. Please can you send me 
a working version I can benchmark and compare? 

Graeme. 



On Sep 5, 2013, at 8:52 PM, <numpy-discussion-requ...@scipy.org>
 wrote:

> 
> hi,
> its not np.any that is slow in this case its np.array([A, B, C])
> 
> np.dstack([A, B, C]) is better but writing it like this has the same
> performance as your code:
> a = empty([3] list(A.shape)
> a[0] = A>5; a[1] = B<2; a[2] = A>10;
> np.any(a, 0)
> 
> I'll check if creating an array from a sequence can be improved for this
> case.

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

Reply via email to