Fernando Perez wrote: > In [8]: N.array(3).shape > Out[8]: () > In [11]: N.array([]).shape > Out[11]: (0,)
> I guess my only remaining question is: what is the difference between > outputs #8 and #11 above? Is an empty shape tuple == array scalar, > while a (0,) shape indicates a one-dimensional array with no elements? > If this interpretation is correct, what is the usage of the latter > kind of object, given how it can't even be indexed? It can be iterated over (with zero iterations): >>> a = N.array([]) >>> for i in a: ... print i ... whereas the scalar can not: >>> b = N.array(3) >>> b array(3) >>> for i in b: ... print i ... Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: iteration over a scalar (0-dim array) Of course the scalar isn't empty, so ti's different in that way too. Can there be an empty scalar? It doesn't look like it. In fact, this looks like it may be a bug: >>> a = N.array([1,2,3]).sum(); a.shape; a.size; a () 1 6 That's what I'd expect, but what if you start with a (0,) array: >>> a = N.array([]).sum(); a.shape; a.size; a () 1 0 where did that zero come from? >>> N.__version__ '1.0b4' -Chris -- Christopher Barker, Ph.D. Oceanographer NOAA/OR&R/HAZMAT (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception [EMAIL PROTECTED] ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion