[NumPy-Tickets] [NumPy] #1921: method index and coords of flatiter object are one-off

NumPy Trac numpy-tickets@scipy....
Tue Aug 2 09:18:29 CDT 2011


#1921: method index and coords of flatiter object are one-off
----------------------+-----------------------------------------------------
  Reporter:  rvdb     |       Owner:  somebody   
      Type:  defect   |      Status:  closed     
  Priority:  normal   |   Milestone:  Unscheduled
 Component:  Other    |     Version:  1.5.1      
Resolution:  invalid  |    Keywords:             
----------------------+-----------------------------------------------------
Changes (by rgommers):

  * status:  new => closed
  * resolution:  => invalid


Comment:

 In the for-loop you already extracted the first value from a with the
 iterator (i.e. called fla.next() once), so the index is that of the second
 element already.
 {{{
 >>> a = np.ones((3, 3))
 >>> fl = a.flat
 >>> fl.index
 0
 >>> fl.coords
 (0, 0)
 >>> fl.next()
 1.0
 >>> fl.index
 1
 >>> fl.coords
 (0, 1)
 >>> fl.next()
 1.0
 }}}

-- 
Ticket URL: <http://projects.scipy.org/numpy/ticket/1921#comment:1>
NumPy <http://projects.scipy.org/numpy>
My example project


More information about the NumPy-Tickets mailing list