[Numpy-discussion] dtype=object behavior change from 0.9.6 to beta 1
Christopher Barker
Chris.Barker at noaa.gov
Thu Aug 31 15:51:07 EDT 2006
Tom Denniston wrote:
> I would think one would want to throw an error when the data has
> inconsistent dimensions.
But it doesn't have inconsistent dimensions - they are perfectly
consistent with a (2,) array of objects. How is the code to know what
you intended?
With numeric types, it is unambiguous to march down through the
sequences until you get a number. As a sequence is an object, there no
way to unambiguously do this automatically.
Perhaps the way to solve this is for the array constructor to take a
"shape" or "rank" argument, so you could specify what you intend. But
that's really just syntactic sugar to avoid for calling numpy.empty() first.
Perhaps a numpy.object_array() constructor would be useful, although as
I think about it, even specifying a shape or rank would not be unambiguous!
This is a useful discussion. If we ever get a nd-array into the standard
lib, I suspect that object arrays will get heavy use -- better to clean
up the semantics now.
Perhaps a Wiki page on building object arrays is called for.
-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
Chris.Barker at noaa.gov
More information about the NumPy-Discussion
mailing list