I'm filling a numpy grid with lists of unknown size because list.append is better to use than np.concatenate (perhaps I'm optimizing prematurely, though).
These don't work:
foo = np.full((3, 4), [])
bar = np.full((3, 4), [], dtype=object)
Numpy just assumes that my [] is a numpy array for populating the result and is the wrong shape.
It works for dicts:
foo = np.full((3, 4), {})
Is there some way to do this?
Edit: actually, I don't know how to do this even with numpy arrays. I want a 2x2 grid with variable length lists or arrays in each cell.
Edit 2: what I really want is something like scipy.stats.binned_statistic_2d but instead of a statistic in each bin, I want to keep the source data.
fulland mutable objects is it puts a reference to the same object in each slot, so you end up with the same sort problems as with making a list of lists with[{}]*3numpy.ndarrayoflistobjects makes no sense. Annd.arrayof dtype=object is pretty much just a crappy, less efficient list. Just use a list of lists.