[Numpy-discussion] ufuncs on funny strides; also isnan, isfinite, etc on a variety of dtypes

M Trumpis mtrumpis@berkeley....
Thu Apr 1 13:30:40 CDT 2010


Hi all,

disclaimer: pardon my vast ignorance on the subject of ufuncs, that
will explain the naivety of the following questions

This morning I was looking at this line of code, which was running
quite slow for me and making me think

data_has_nan = numpy.isnan(data_array).any()

I knew that the array was of type uint8. This raised the question of
how much slower would a function like isnan() run on integer typed
data, and furthermore if it's integer typed data then why bother
looking at the values at all?

Actually I realized later that the main slow-down comes from the fact
that my array was strided in fortran order (ascending strides). But
from the point of view of a ufunc that is operating independently at
each value, why would it need to respect striding?

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.

Kind regards,
Mike


More information about the NumPy-Discussion mailing list