I may be missing something obvious here, but I am missing a function numpy.map
. What that would be is the same as Python's map
function, but collect the output in a numpy
array. For example, I could have an image generator genImage(i)
that generates a 2D image (of size (m, n)
) based on a single input, and I would like to input range(k)
to my generator function and obtain a (k, m, n)
array.
Currently, I would use numpy.array(list(map(genImage, range(k)))
, but I feel that this conversion into a list is rather inefficient (my final array is about 50 GB in size). I am thus looking for numpy.map(genImage, range(k))
, which is similar to numpy.fromiter
, but for multidimensional outputs of the iterator.
(I have tried np.array(map(...))
, but that returns a one-element array with the map as it's only entry - here is why: Why is it required to typecast a map into a list to assign it to a pandas series?)
Is there a better way to achieve what I want? I am looking to a way that ideally, I could use with joblib
.