[Numpy-tickets] [NumPy] #636: Faster array version of ndindex

NumPy numpy-tickets@scipy....
Tue Feb 12 03:26:48 CST 2008


#636: Faster array version of ndindex
----------------------------+-----------------------------------------------
 Reporter:  jarrod.millman  |        Owner:  jarrod.millman
     Type:  enhancement     |       Status:  new           
 Priority:  normal          |    Milestone:  1.0.5         
Component:  Other           |      Version:  none          
 Severity:  normal          |   Resolution:                
 Keywords:                  |  
----------------------------+-----------------------------------------------
Comment (by stefan):

 This is simply a fast implementation of array(list(np.index(...))) -- i.e.
 an N-dimensional counter.  I think one should be able to build it using
 currently available functions, since you can also see it as a special
 flattening of np.mgrid, i.e. in two dimensions
 it is roughly equivalent to np.mgrid[0:m,0:n].T.reshape(-1,2).  So the
 following should do the trick:

 {{{
 def ndi(shape):
   return np.indices(shape).T.reshape(-1,len(shape))
 }}}

 I will open a ticket for ndi((0,3,4)), which currently segfaults.

 We'll have to ask Jonathan for use cases of the above -- I don't have any.

-- 
Ticket URL: <http://scipy.org/scipy/numpy/ticket/636#comment:5>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.


More information about the Numpy-tickets mailing list