Re: [Numpy-discussion] strange behavior with a numpy array as member of a list

2006-11-30 Thread Robert Kern
Christopher Barker wrote: > > Robert Kern wrote: > >>> What determines if an array tests for equality as the entire array or >>> element-wise? >> There are some special cases for backwards compatibility. > > with what? > > IIRC, Numeric has raised an error for a very long time with: > > a ==

Re: [Numpy-discussion] strange behavior with a numpy array as member of a list

2006-11-30 Thread Christopher Barker
Robert Kern wrote: >> What determines if an array tests for equality as the entire array or >> element-wise? > > There are some special cases for backwards compatibility. with what? IIRC, Numeric has raised an error for a very long time with: a == None #(a is a Numeric array) Personally,

Re: [Numpy-discussion] strange behavior with a numpy array as member of a list

2006-11-30 Thread Tim Hirzel
Excellent. That explains it. thank you Robert, tim Robert Kern wrote: > Tim Hirzel wrote: > >> Thanks Robert. >> That makes more sense now. Although I am still a little puzzled by the >> equality behavior of an array. for example: >> >> >>> a = numpy.arange(5) >> >>> None == a >> False >>

Re: [Numpy-discussion] strange behavior with a numpy array as member of a list

2006-11-30 Thread Robert Kern
Tim Hirzel wrote: > Thanks Robert. > That makes more sense now. Although I am still a little puzzled by the > equality behavior of an array. for example: > > >>> a = numpy.arange(5) > >>> None == a > False > > >>> 5 == a > array([False, False, False, False, False], dtype=bool) > > >>> cla

Re: [Numpy-discussion] strange behavior with a numpy array as member of a list

2006-11-30 Thread Tim Hirzel
Thanks Robert. That makes more sense now. Although I am still a little puzzled by the equality behavior of an array. for example: >>> a = numpy.arange(5) >>> None == a False >>> 5 == a array([False, False, False, False, False], dtype=bool) >>> class Empty: pass >>> e = Empty() >>> e

Re: [Numpy-discussion] strange behavior with a numpy array as member of a list

2006-11-30 Thread Robert Kern
Tim Hirzel wrote: > Does this seem odd to anyone else? I am not sure about the > implementation of 'in' but it seems like a comparison is going funny > somewhere. Or I am missing something... Yes, list.__contains__ uses equality to test for membership, not identity. -- Robert Kern "I have c

[Numpy-discussion] strange behavior with a numpy array as member of a list

2006-11-30 Thread Tim Hirzel
Hi All, When a list contains a numpy array and I want to see if a value is a member of that list, I can get a value error from numpy: >>> import numpy >>> numpy.__version__ '1.0' >>> a = numpy.arange(10) >>> L = [a] >>> a in L True >>> 2 in L Traceback (most recent call last): File "", lin