[Numpy-discussion] TypeError in dtype.__eq__()
Bryan Cole
bryan@cole.uklinux....
Sun Jan 11 10:19:51 CST 2009
> >
> > What's the consensus on this? Is the current dtype behaviour broken?
>
> It's suboptimal, certainly. Feel free to fix it.
Thankyou.
> However, also note
> that with ndarray's rich comparisons, such membership testing will
> fail with ndarrays, too.
This poses a similarly big problem. I can't understand this behaviour
either:
>>> a = numpy.array([1.2,3.4])
>>> a == 6.5
array([False, False], dtype=bool)
>>> a == numpy.array([1,2])
array([False, False], dtype=bool)
>>> a == "foo"
False
>>> a in [1,2,3]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: The truth value of an array with more than one element is
ambiguous. Use a.any() or a.all()
Surely this is a bug?! This membership testing operation is quite
reasonable. If list.__contains__ is calling ndarray.__eq__(), this ought
to succeed. Why does this fail? (and I fail to see how any() or all()
can resolve the situation).
I need to go check what list.__contains__() is doing...
BC
More information about the Numpy-discussion
mailing list