I would think one would want to throw an error when the data has inconsistent dimensions.  This is what numpy does for other dtypes:

In [10]: numpy.array(([1,2,3], [4,5,6]))
array([[1, 2, 3],
       [4, 5, 6]])

In [11]: numpy.array(([1,3], [4,5,6]))
exceptions.TypeError                                 Traceback (most recent call last)

TypeError: an integer is required


On 8/31/06, Christopher Barker <Chris.Barker@noaa.gov> wrote:
Tom Denniston wrote:
> So my question is what is the _advantage_ of the new semantics?

what if the list don't have the same length, and therefor can not be
made into an array, now you get a weird result:


Now you get an Object scalar.


Now you get a length 2 array, just like before: far more consistent.
With the old semantics, if you test your code with arrays of different
lengths, you'll get one thing, but if they then happen to be the same
length in some production use, the whole thing breaks -- this is a Bad Idea.

Object arrays are just plain weird, there is nothing you can do that
will satisfy every need. I think it's best for the array constructor to
not try to guess at what the hierarchy of sequences you *meant* to use.
You can (and probably should) always be explicit with:

>>> A = N.empty((2,), dtype=object)
>>> A
array([None, None], dtype=object)
>>> A[:] = [N.array([1,'A', None],
>>> A
array([[1 A None], [2 2 Somestring 5]], dtype=object)


Christopher Barker, Ph.D.

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


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
Numpy-discussion mailing list