>>> s = {0, 4, 27}
>>> a = numpy.arange(10)
>>> t = some_func(a)
>>> t
[1, 0, 0, 0, 1, 0, 0, 0, 0, 0]
What's the canonical some_func needed to be to make this work?
What I've tried
I've tried vectorizing a lambda function, which works ... it just doesn't feel like the right way to do this.
>>> f = lambda i: i in s
>>> vf = numpy.vectorize(f)
>>> t = numpy.fromfunction(vf, a.shape)
>>> t.astype(int)
array([1, 0, 0, 0, 1, 0, 0, 0, 0, 0])
numpy, but would something like[i in s for i in a]work here?