[Numpy-discussion] Problem with concatenate and object arrays

Charles R Harris charlesr.harris at gmail.com
Wed Sep 13 20:07:39 CDT 2006

On 9/13/06, Matthew Brett <matthew.brett at gmail.com> wrote:
> Hi,
> > For example, if you do array([a,b,c]).shape(), the answer is normally
> > (3,) unless a b and c happen to all be lists of the same length, at
> > which point your array could have a much more complicated shape... but
> > as the person who wrote "array([a,b,c])" it's tempting to assume that
> > the result has shape (3,), only to discover subtle bugs much later.
> Very much agree with this.
> > If we were writing an array-creation function from scratch, would
> > there be any reason to include object-array creation in the same
> > function as uniform array creation? It seems like a bad idea to me.
> >
> > If not, the problem is just compatibility with Numeric. Why not simply
> > write a wrapper function in python that does Numeric-style guesswork,
> > and put it in the compatibility modules? How much code will actually
> > break?
> Can I encourage any more comments?  This suggestion seems very
> sensible to me, and I guess this is our very last chance to change
> this. The current behavior does seem to violate least surprise - at
> least to my eye.

I've been thinking about how to write a new constructor for objects. Because
array has been at the base of numpy for many years I think it is too late to
change it now, but perhaps a new and more predictable constructor for
objects may eventually displace it. The main problem in constructing arrays
of objects is more information needs to be supplied because the user's
intention can't be reliably deduced from the current syntax. That said, I
have no idea how widespread the use of object arrays is and so don't know
how much it really matters. I don't use them much myself.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20060913/96772131/attachment.html 

More information about the Numpy-discussion mailing list