[NumPy-Tickets] [NumPy] #1729: Wrong behavior: asarray & object with __array__ sets owndata to True

NumPy Trac numpy-tickets@scipy....
Wed Feb 2 16:19:21 CST 2011


#1729: Wrong behavior: asarray & object with __array__ sets owndata to True
------------------------+---------------------------------------------------
 Reporter:  pv          |       Owner:  somebody
     Type:  defect      |      Status:  new     
 Priority:  normal      |   Milestone:  2.0.0   
Component:  numpy.core  |     Version:  1.5.0   
 Keywords:              |  
------------------------+---------------------------------------------------

Comment(by pv):

 The problem here is in the design: consider code such as
 {{{
 y = np.asarray(x)
 copy_made = y is not x and y.flags.owndata
 }}}
 Seems idiomatic on the surface, but objects implementing `__array__`
 behave in a different way from objects implementing `__array_interface__`.

 Of course, at present it is not very clearly documented what `__array__`
 is supposed to return, so this may also be a documentation problem. The
 `ndarray.__array__` docstring says "Returns either a new reference to self
 if dtype is not given or a new array ...".

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


More information about the NumPy-Tickets mailing list