Skip to content Skip to sidebar Skip to footer

Why Can I Not Replicate The Numpy V1.13.dev0 Manual Examples

As an example I am reading through the following: https://docs.scipy.org/doc/numpy-dev/neps/new-iterator-ufunc.html So I run a bit of code on my computer using iPython shown for ex

Solution 1:

Just to be clear the In[4] and [9] times are copied from that 6 yr old document. The [12][13] times are from your own tests (and basically the same as what I get). I haven't studied that old dev document, but have run the np.nditer examples on

https://docs.scipy.org/doc/numpy/reference/arrays.nditer.html

and know that nditer does not normally speed code. This iterator is meant to be used in C level code, and its exposure at the Python level is a convenience. It lets us test ideas in Python code before moving them to C or Cython. Note the Cython example at the end. Even so, I found I could get better speed in a simple multiplication case by using Cython memoryviews.

np.ndindex is one of the few numpy functions that uses np.nditer in Python code. I've occasionally suggested a similar pattern to produce depth limited iteration.

So don't worry too much about mastering np.nditer.

Post a Comment for "Why Can I Not Replicate The Numpy V1.13.dev0 Manual Examples"