[Numpy-discussion] initializing an array of lists
Christopher Barker
Chris.Barker@noaa....
Mon Nov 9 12:00:30 CST 2009
alan@ajackson.org wrote:
> myarray = zeros( (xdim,ydim), dtype=object)
> and then iterate through the elements initializing then to empty lists, but
> surely there is a better way.
I tried this:
In [3]: a = np.empty((2,3), dtype=np.object)
In [5]: a[:,:] = []
but got:
ValueError: shape mismatch: objects cannot be broadcast to a single shape
Is that a bug? Or is it simply too ambiguous for numpy to figure out
what the heck I want?
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov
More information about the NumPy-Discussion
mailing list