[Numpy-discussion] setting the same object value with a mask?

Thomas Tanner tanner@gmx...
Mon Apr 16 10:50:24 CDT 2012


Hi,
is there an elegant method for assigning the same value to several
indices in a ndarray? (in this case with dtype=object)

example:

a = empty(4,'O') # object ndarray
x = [1,2,'f'] # the value to be set for some indicies - the value is not
scalar
a[array((True,False,True))] = x # works like put -> not what I want
a[array((0,2))] = x # same effect
print a # -> [1 None 2 None]
a[0],a[2] = x,x # set explicitly - works
print a # -> [[1, 2, 'f'] None [1, 2, 'f'] None]

thanks for your help!

cheers,
-- 
Thomas Tanner ------
email: tanner@gmx.de
GnuPG: 1024/5924D4DD


More information about the NumPy-Discussion mailing list