Is there a way to do a numpy array comprehension in Python? The only way I have seen it does is by using list comprehension and then casting the results as a numpy array, e.g. np.array(list comprehension)
. I would have expected there to be a way to do it directly using numpy arrays, without using lists as an intermediate step.
Also, is it possible to overload list operators, i.e. [
and ]
, so that the results is a numpy array, not a list.