[Numpy-discussion] dtype=object behavior change from 0.9.6 to beta 1
Tom Denniston
tom.denniston at alum.dartmouth.org
Thu Aug 31 13:11:22 CDT 2006
wrote the last email before reading your a = array([1,'A', None]) comment.
I definately agree with you on that.
On 8/31/06, Tom Denniston <tom.denniston at alum.dartmouth.org> wrote:
>
> Yes one can take a toy example and hack it to work but I don't
> necessarily have control over the input as to whether it is a list of object
> arrays, list of 1d heterogenous arrays, etc. Before I didn't need to worry
> about the input because numpy understood that a list of 1d arrays is a
> 2d piece of data. Now it understands this for all dtypes except object. My
> question was is this new set of semantics preferable to the old.
>
> I think your example kind of proves my point. Does it really make any
> sense for the following two ways of specifying an array give such different
> results? They strike me as _meaning_ the same thing. Doesn't it seem
> inconsistent to you?
>
>
> In [13]: array([array([1,'A', None], dtype=object),array([2,2,'Some
> string'],dtype=object)], dtype=object).shape
> Out[13]: (2,)
>
> and
>
> In [14]: array([array([1,'A', None], dtype=object),array([2,2,'Some
> string'],dtype=object)]).shape
> Out[14]: (2, 3)
> So my question is what is the _advantage_ of the new semantics? The two
> examples above used to give the same results. In what cases is it
> preferable for them to give different results? How does it make life
> simpler?
>
>
> On 8/31/06, Charles R Harris <charlesr.harris at gmail.com> wrote:
>
> > On 8/31/06, Tom Denniston <tom.denniston at alum.dartmouth.org > wrote:
>
> > But i have hetergenious arrays that have numbers and strings and
> > NoneType, etc.
> >
> > Take for instance:
> >
> > In [11]: numpy.array([numpy.array([1,'A', None]),
> > numpy.array([2,2,'Some string'])], dtype=object)
> > Out[11]:
> > array([[1, A, None],
> > [2, 2, Some string]], dtype=object)
> >
> > In [12]: numpy.array([ numpy.array([1,'A', None]),
> > numpy.array([2,2,'Some string'])], dtype=object).shape
> > Out[12]: (2, 3)
> >
> > Works fine in Numeric and pre beta numpy but in beta numpy versions i
> > get:
>
>
> I think you want:
>
> In [59]: a = array([array([1,'A', None],dtype=object),array([2,2,'Some
> string'],dtype=object)])
>
> In [60]: a.shape
> Out[60]: (2, 3)
>
>
> Which makes good sense to me.
>
> Chuck
>
>
>
>
>
> -------------------------------------------------------------------------
> 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 at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20060831/0e366932/attachment.html
More information about the Numpy-discussion
mailing list