[Numpy-discussion] behavior of 'insert' for inserting multiple values
Stéfan van der Walt
stefan@sun.ac...
Tue May 27 04:26:27 CDT 2008
Hi Mark
2008/5/27 mark <markbak@gmail.com>:
>>>> a = arange(5.)
>>>> insert(a,3,[7,7])
> array([ 0., 1., 2., 7., 3., 4.])
>
> But insert only inserts one of the 7's, while I want both values to be
> inserted. Nor does numpy throw a warning (which I think would be
> appropriate). The way that works correctly is
>
>>>> insert(a,[3,3],[7,7])
> array([ 0., 1., 2., 7., 7., 3., 4.])
You need to specify two insertion positions, i.e.
np.insert(a, [3, 3], [7, 7])
I think we should consider a special case for your example, though.
Regards
Stéfan
More information about the Numpy-discussion
mailing list