[Numpy-discussion] possible bug with numpy.object_
Stefan van der Walt
stefan at sun.ac.za
Wed Aug 30 08:04:16 EDT 2006
On Tue, Aug 29, 2006 at 10:49:58AM -0600, Travis Oliphant wrote:
> Matt Knox wrote:
> > is the following behaviour expected? or is this a bug with
> > numpy.object_ ? I'm using numpy 1.0b1
> >
> > >>> print numpy.array([],numpy.float64).size
> > 0
> >
> > >>> print numpy.array([],numpy.object_).size
> > 1
> >
> > Should the size of an array initialized from an empty list not always
> > be 1 ? or am I just crazy?
> >
> Not in this case. Explictly creating an object array from any object
> (even the empty-list object) gives you a 0-d array containing that
> object. When you explicitly create an object array a different section
> of code handles it and gives this result. This is a recent change, and
> I don't think this use-case was considered as a backward incompatibility
> (which I believe it is). Perhaps we should make it so array([],....)
> always returns an empty array. I'm not sure. Comments?
The current behaviour makes sense, but is maybe not consistent:
N.array([],dtype=object).size == 1
N.array([[],[]],dtype=object).size == 2
Regards
Stéfan
More information about the NumPy-Discussion
mailing list