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

NumPy Trac numpy-tickets@scipy....
Wed Feb 2 15:32:27 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 m-paradox):

 I think this is working as expected, because Fake never makes a view of
 the array.
 Observe:

 {{{
 >>> import numpy as np
 >>> class Fake(object):
 ...     def __init__(self, data):
 ...         self._data = data
 ...     def __array__(self):
 ...         return self._data
 ...
 >>> x = np.array([1,2,3])
 >>> print np.asarray(Fake(x)).flags.owndata
 True
 >>> np.asarray(Fake(x)) is x
 True
 }}}

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


More information about the NumPy-Tickets mailing list