[Numpy-discussion] Should 0-d arrays with fields defined return a 0-d array or a scalar

Travis Oliphant oliphant.travis at ieee.org
Thu Mar 29 15:20:55 EDT 2007


Hi all,

Ticket #474 discusses the problem that getting a field from a 0-d array 
automatically produces a scalar (which then cannot be set).
This produces the problem that recarrays code must often special-case 
the 0-d possibility.

Thus,

rarr.x[...] = blah

doesn't work for 0-d arrays because rarr.x is a scalar.

It makes some sense to make field selection for 0-d arrays return 0-d 
arrays as consistent with the changes that were made prior to the 1.0 
release to allow persistence of 0-d arrays.

However, changing field selection to return 0-d arrays does change 
behavior.  A 0-d array is not a scalar (the 0-d array is not hashable 
for example, and the 0-d string array does not inherit from the Python 
string).  Thus, just making the change, may not be advised.

It is easy to account for and fix any errors that might arise.  But, we 
are in a major release, I need some advice as to whether or not this is 
a "bug-fix" or a feature enhancement that must wait for 1.1?

Any stake holders in the current behavior of arrays with records?


-Travis




More information about the NumPy-Discussion mailing list