Questions on migrating from Numeric/Scipy to Numpy

vj vinjvinj at gmail.com
Tue Mar 13 21:22:50 EDT 2007


I've tried to post this to the numpy google group but it seems to be
down. My migration seems to be going well. I currently have one issue
with using scipy_base.insert.

>>> a = zeros(5)
>>> mask = zeros(5)
>>> mask[1] = 1
>>> c = zeros(1)
>>> c[0] = 100
>>> numpy.insert(a, mask, c)
array([ 100.,    0.,  100.,  100.,  100.,    0.,    0.,    0.,
0.,    0.])
>>> a
array([ 0.,  0.,  0.,  0.,  0.])
>>> b
array([0, 0, 0, 0, 0, 0, 0, 0, 0, 1], dtype=int8)
>>> mask
array([ 0.,  1.,  0.,  0.,  0.])
>>> c
array([ 100.])

I would have expected numpy.insert to update a so that the second
element in a would be 100.

Thanks,

VJ




More information about the Python-list mailing list