This is an annoying side effect of how numpy deals with the comparison operator ==.
Consider this:
>>> print(1 == np.array([1,2,3]))
[ True False False]
Clearly the array np.array([1,2,3]) is not 1, but what the expression computes is if all elements on the array are 1 and the result is an array with booleans.
This does what you need, keeping that in mind:
if any((test==a).all() for a in many):
print('yes')
To explain why yours doesn't work:
if np.array([23, 34, 12]) in many:
This basically amounts to:
if any(x == np.array([23, 34, 12]) for x in many):
And you now know that the result would be like: any([False, False, False], [False, False, False], [False, False, False]) - and any cannot deal with the lists.
After reading the other answer, I wondered about execution times:
from timeit import timeit
import numpy as np
many = [np.array([23, 34, 12]), np.array([23, 34, 23]), np.array([45, 23, 48])]
test = np.array([23, 34, 23])
def one():
return any((test == a).all() for a in many)
def two():
for a in many:
if np.array_equal(a, test):
return True
return False
def three():
return (many == test).all(axis=1).any(axis=0)
def four():
return test.tolist() in np.stack(many).tolist()
n = 1000000
print('one():', timeit(one, number=n), one())
print('two():', timeit(two, number=n), two())
print('three():', timeit(three, number=n), three())
print('four():', timeit(four, number=n), four())
Results:
one(): 3.0405494 True
two(): 5.1088635 True
three(): 5.7222043 True
four(): 4.961463499999999 True
So, for performance the solution provided in this answer is fastest. Of course, you may prefer an alternative for style.
Under perhaps somewhat more realistic workloads, three() may perform faster. For 10,000 arrays of 1,000 random elements searching for a random 1,000 array, one() still easily outperforms it, but as the number of searched arrays increases and the size of the searched arrays doesn't, three() inches it out.
For example, in my situation, when searching for a random 100 element array in a 1,000,000 random element arrays, three() is about twice as fast as one(). You'll need to decide which solution you prefer based on the type of search you're performing.
As with any "what is the fastest solution" question, the answer is always "it depends" and realistic testing is the way to find your answer.