I often do the following:
import numpy as np
def my_generator_fun():
yield x # some magically generated x
A = []
for x in my_generator_fun():
A += [x]
A = np.array(A)
Is there a better solution to this which operates on a numpy array from the start and avoids the creation of a standard python list?
Note that the += operator allows to extend an empty and dimensionless array with an arbitrarily dimensioned array whereas np.append and np.concatenate demand for equally dimensioned arrays.