[Numpy-discussion] searching a list of arrays

Darren Dale dd55 at cornell.edu
Sun Mar 27 15:22:08 EST 2005


Hi,

I have a list of numeric-23.8 arrays:

a = [array([0,1]),
      array([0,1]),
      array([1,0]),
      array([1,0])]

b = [array([0,1,0]),
      array([0,1,0]),
      array([1,0,0]),
      array([1,0,0])]

and I want to make a new list out of b:

c = [array([0,1,2]),
      array([1,0,2])]

where the last index in each array is the result of

b.count([0,1,0]) # or [1,0,0]


The problem is that the result of b.count(array([1,0,0])) is 4, not 2, and 
b.remove(array([1,0,0])) indescriminantly removes arrays from the list. 
a.count and a.remove work the way I expected.

Does anyone know why 1x2 arrays work, but 1x3 or larger arrays do not?

Thanks,
Darren




More information about the NumPy-Discussion mailing list