Closed
Description
When I test a single-element NumPy array against a regular Python list, np.array([1]) != []
, the result evaluates to neither true nor false, while one of multiple elements evaluates to true. E.g. 'boo' is printed with the following:
a = np.array([1])
b = np.array([1,2])
if a != []:
print("foo")
if a == []:
print("moo")
if b != []:
print("boo")
Using the interpreter:
>>> import numpy as np
>>> a = np.array([1])
>>> b = np.array([1,2])
>>> a != []
array([], dtype=bool)
>>> a == []
array([], dtype=bool)
>>> b == []
False
This seems strange. Was this intended?
Tested with Python 2.7.10 and 3.4.2, using Numpy 1.10.1.
Linux 4.2.6-200.fc22.x86_64 (Fedora 22)