[NumPy-Tickets] [NumPy] #2117: inconsistent comparison of object type arrays

NumPy Trac numpy-tickets@scipy....
Fri Apr 27 04:11:25 CDT 2012


#2117: inconsistent comparison of object type arrays
------------------------+---------------------------------------------------
 Reporter:  yarikoptic  |       Owner:  somebody   
     Type:  defect      |      Status:  new        
 Priority:  normal      |   Milestone:  Unscheduled
Component:  Other       |     Version:  1.6.1      
 Keywords:              |  
------------------------+---------------------------------------------------

Comment(by charris):

 Strange indeed. This is going to be fun to figure out. My guess it that
 the first item is the same object in a and a.copy(), whereas it is a
 different object for the other array created with the same parameters...
 and it is so.


 {{{
 In [12]: b = np.array([np.array([0, 1]), np.array(1)], dtype=object)

 In [13]: type b[1]
 -------> type(b[1])
 Out[13]: numpy.ndarray

 In [14]: c = b.copy()

 In [15]: c[0] is b[0]
 Out[15]: True

 In [16]: d = np.array([0,1])

 In [17]: c[0] is d
 Out[17]: False

 }}}

 So the comparison is comparing object pointers rather than calling a
 comparison routine. It's certainly easier to compare the pointers. I'm not
 sure if this is a bug or a feature ;) Shouldn't be hard to find where it
 happens.

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


More information about the NumPy-Tickets mailing list