def padone(x, front=0, back=0, axis=0, fillvalue=0):
 shape = np.array(x.shape)
 shape[axis] += (front + back)
 shapearr = np.array(x.shape)
 out = np.empty(shape)
 out.fill(fillvalue)
 startind = np.zeros(x.ndim)
 startind[axis] = front
 endind = (startind + shapearr)
 myslice = [slice(startind[k], endind[k]) for k in range(len(endind))]
 out[tuple(myslice)] = x
 return out

def padone ( x , front = 0 , back = 0 , axis = 0 , fillvalue = 0 ) : shape = np . array ( x . shape ) shape [ axis ] += ( front + back ) shapearr = np . array ( x . shape ) out = np . empty ( shape ) out . fill ( fillvalue ) startind = np . zeros ( x . ndim ) startind [ axis ] = front endind = ( startind + shapearr ) myslice = [ slice ( startind [ k ] , endind [ k ] ) for k in range ( len ( endind ) ) ] out [ tuple ( myslice ) ] = x return out
pad with zeros along one axis .