[Numpy-discussion] ufuncs on funny strides; also isnan, isfinite, etc on a variety of dtypes
Warren Weckesser
warren.weckesser@enthought....
Thu Apr 1 13:53:39 CDT 2010
M Trumpis wrote:
> Hi all,
>
> <snip>
>
> And a last mini question, it doesn't appear that any() is doing short
> circuit evaluation. It runs in appx the same time whether an array is
> sparsely nonzero, fully zero, or fully nonzero.
>
>
That's not what I see. Here's an example that shows the a linear
increase in time:
In [112]: x = np.zeros((1000,1000), dtype=bool)
In [113]: y = np.zeros((1000,1000), dtype=bool)
In [114]: z = np.zeros((1000,1000), dtype=bool)
In [115]: x[0,0] = 1
In [116]: y[500,0] = 1
In [117]: z[-1,-1] = 1
In [118]: %timeit x.any()
100000 loops, best of 3: 4 us per loop
In [119]: %timeit y.any()
1000 loops, best of 3: 566 us per loop
In [120]: %timeit z.any()
1000 loops, best of 3: 1.13 ms per loop
Warren
> Kind regards,
> Mike
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
More information about the NumPy-Discussion
mailing list