[Numpy-discussion] How construct custom slice

Mario Moura moura.mario@gmail....
Mon Dec 27 12:36:38 CST 2010


Hi Folks

a = np.zeros((4,3,5,55,5),dtype='|S8')
myLen = 4 # here I use myLen = len(something)
li = [3,2,4] # li from a list.append(something)
sl = slice(0,myLen)
tmpIndex = tuple(li) + sl + 4  # <== Here my problem
a[tmpIndex]

# So What I want is:
fillMe = np.array(['foo','bar','hello','world'])
# But I cant contruct by hand like this
a[3,2,4,:4,4] = fillMe
a

Again. I need construct custom slice from here
tmpIndex = tuple(li) + sl + 4
a[tmpIndex]

Who can help me?

Best Regards

Mario Moura


More information about the NumPy-Discussion mailing list