I'm trying to work around the issue of building a numpy array using a generator as noted here. To get around this I define the following function:
list_of_np_arrays = []
for i in generator:
list_of_np_arrays.append(np.array(i)) # i shape is (n:2)
# convert list to numpy array
list_of_np_arrays = np.asarray(list_of_np_arrays)
I have:
array([array([[ 0, 1],
[ 1, 1],
[ 2, 1],
[1004, 3],
[1005, 1],
[1006, 1]]),
array([[ 12, 1],
[ 23, 2],
[ 25, 1],
[1665, 2],
[1666, 1],
[1667, 1]])], dtype=object)
I want:
array([
[ 0, 1],
[ 1, 1],
[ 2, 1],
[1004, 3],
[1005, 1],
[1006, 1],
[ 12, 1],
[ 23, 2],
[ 25, 1],
[1665, 2],
[1666, 1],
[1667, 1]], dtype=object)
Is there a best practice for handling this situation?