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

mark markbak at gmail.com
Fri Mar 30 10:41:22 EDT 2007


Does this mean, we could do something like this?

a = 3
a = array(a)
a[ a<4 ] = 5

If so, that would be great!

Mark

On Mar 29, 9:20 pm, Travis Oliphant <oliphant.tra... at ieee.org> wrote:
> 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
>
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discuss... at scipy.orghttp://projects.scipy.org/mailman/listinfo/numpy-discussion




More information about the NumPy-Discussion mailing list