2010/8/1 Matthew Brett matthew.br...@gmail.com:
Maybe it would be better to raise a ValueError, which is not caught by
the evaluation mechanism, to prevent such stuff.
Sorry that this is not yet clear to me, but, is it true then that:
The only situation where array.__eq__ sensibly falls back
2010/7/29 Keith Goodman kwgood...@gmail.com:
On Wed, Jul 28, 2010 at 6:42 PM, Matthew Brett matthew.br...@gmail.com
wrote:
Hi,
Please forgive me if this is obvious, but this surprised me:
In [15]: x = np.array(['a', 'b'])
In [16]: x == 'a' # this was what I expected
Out[16]: array([
Hi,
Yeah, it's just that numpy knows that it cannot compare pears with apples:
a = numpy.asarray(['a', 'b'])
a.__eq__(1)
NotImplemented
Thank you - that's very helpful and clear.
Maybe it would be better to raise a ValueError, which is not caught by
the evaluation mechanism, to prevent
Hi,
On Wed, Jul 28, 2010 at 6:49 PM, John Salvatier
jsalv...@u.washington.edu wrote:
I think this is just Python behavior; comparing python ints and strs also
gives False:
In [45]: 8 == 'L'
Out[45]: False
Just to be clear, from:
a = np.array(['a','b'])
a == 1
I was expecting:
array([
On Wed, Jul 28, 2010 at 6:42 PM, Matthew Brett matthew.br...@gmail.com wrote:
Hi,
Please forgive me if this is obvious, but this surprised me:
In [15]: x = np.array(['a', 'b'])
In [16]: x == 'a' # this was what I expected
Out[16]: array([ True, False], dtype=bool)
In [17]: x == 1 # this
I think this is just Python behavior; comparing python ints and strs also
gives False:
In [45]: 8 == 'L'
Out[45]: False
On Wed, Jul 28, 2010 at 6:42 PM, Matthew Brett matthew.br...@gmail.comwrote:
Hi,
Please forgive me if this is obvious, but this surprised me:
In [15]: x = np.array(['a',
In [15]: x = np.array(['a', 'b'])
In [16]: x == 'a' # this was what I expected
Out[16]: array([ True, False], dtype=bool)
In [17]: x == 1 # this was strange to me
Out[17]: False
Is it easy to explain why this is?
I'll call this a bug in NumPy's broadcasting. x == 1 should have
I'll call this a bug in NumPy's broadcasting. x == 1 should have
returned:
This is probably related:
In [22]: a = np.array(['a','b'])
In [23]: a + 'c'
---
TypeError Traceback (most recent
I'll call this a bug in NumPy's broadcasting. x == 1 should have
returned:
This is probably related:
In [22]: a = np.array(['a','b'])
In [23]: a + 'c'
---
TypeError Traceback (most