I want to declare an array of object and later to include arrays in it. I can do it this way:
import numpy as np
v = np.empty([2,2], dtype=object)
for i in range(len(v.flat)):
v.flat[i] = np.ones([3])
But since Numpy has iterators, I wanted to use them:
v = np.empty([2,2], dtype=object)
for i in np.nditer(v, flags=['refs_ok'],op_flags=['readwrite']):
i[...] = np.ones([3])
and the message is:
ValueError: could not broadcast input array from shape (3) into shape()
Can someone explain my how to do it correctly?
TIA
i.fill(numpy.ones([3]))seems to work.i[...] =is wrong or if I should make a "bug" report.v[0, :2] = 1, 2), so I wouldn't regard it as a bug.