On Mon, Feb 14, 2022, at 12:45, Sebastian Berg wrote:
> But this is currently *not* consistently the case.  I wish to make this
> consistent.  The confusion is around object arrays, though:
>
>     value = np.array(None, dtype=object)
>     arr[0] = value
>
> Stores `value` without unpacking it currently.
>
>     arr.fill(value)
>
> Stores the `None` (unpacking `value`) if and only if `value` is 0-D.

That last behavior doesn't look right to me.  An object array should be thought 
of as a collection of pointers, and if you happen to want to point to a NumPy 
array, so be it.

> Further related behaviour is that:
>
>     np.array(value)  # unpacks any array
>     np.array([value, None], dtype=object)  # does not unpack

This seems reasonable. What would another reasonable expectation be?

> Now, we could unpack making it impossible to place a 0-D array into an
> object array except via `arr.itemset()`.

Not sure why we'd do that.

> My current preference is to store the 0-D arrays as-is, and basically
> say that passing a 0-D array as value for:
>
>     arr.fill(0d_arr)
>     arr[0] = 0d_arr  # this is fine: arr[0, ...] = 0d_arr

Does this differ from the current behavior?  It looks to me like object arrays 
get correctly filled and assigned.

Stéfan
_______________________________________________
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com

Reply via email to