[NumPy-Tickets] [NumPy] #1433: numpy array captures 'in' statement when it shouldn't

NumPy Trac numpy-tickets@scipy....
Sun Sep 5 16:08:46 CDT 2010


#1433: numpy array captures 'in' statement when it shouldn't
--------------------------+-------------------------------------------------
  Reporter:  graik        |       Owner:  somebody    
      Type:  enhancement  |      Status:  closed      
  Priority:  normal       |   Milestone:              
 Component:  numpy.core   |     Version:  1.3.0       
Resolution:  wontfix      |    Keywords:  __contains__
--------------------------+-------------------------------------------------
Changes (by pv):

  * status:  reopened => closed
  * resolution:  => wontfix


Comment:

 Well, this design decision has been in place since the beginning of Numpy,
 and revisiting it at this point requires reconsidering the reasons why it
 was put there in the first place. The correct forum for that discussion is
 the mailing list:

     http://mail.scipy.org/mailman/listinfo/numpy-discussion

 Here are some related discussions:

   - http://article.gmane.org/gmane.comp.python.numeric.general/32820
   - http://article.gmane.org/gmane.comp.python.numeric.general/20556
   - http://article.gmane.org/gmane.comp.python.numeric.general/35923

 The main points to note are:

   - `some_array == 0` must return an array (otherwise, essentially all
 Numpy-using code will break)
   - `bool(some_array) == some_array.all()` cannot be used due to `if a !=
 b:`
   - `bool(some_array) == some_array.any()` cannot be used since it leads
 e.g. to the issue with `__contains__`

 Since there is no obvious solution, a ValueError was decided to be the
 best choice.

 Note that the behavior of Numeric was not a "feature", which was
 reconsidered in Numpy. I don't know exactly in which version it was
 introduced,

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


More information about the NumPy-Tickets mailing list