[Numpy-discussion] Difference between shape=() and shape=(1,)

Keith Goodman kwgoodman@gmail....
Tue Jul 13 13:12:26 CDT 2010


On Tue, Jul 13, 2010 at 10:36 AM, Pauli Virtanen <pav@iki.fi> wrote:
> ti, 2010-07-13 kello 10:06 -0700, Keith Goodman kirjoitti:
>> No need to use where. You can just do a[np.isnan(a)] = 0. But you do
>> have to watch out for 0d arrays, can't index into those.
>
> You can, but the index must be appropriate:
>
>>>> x = np.array(4)
>>>> x[()] = 3
>>>> x
> array(3)

Then should this error message be changed?

>> a = np.array(4)
>> a[1]
<snip>
IndexError: 0-d arrays can't be indexed


More information about the NumPy-Discussion mailing list