#NEWLINE# def trimone( x , front = 0 , back = 0 , axis = 0 ) : #NEWLINE# #INDENT# 'trim number of array elements along one axis\n\n\n    Examples\n    --------\n    >>> xp = padone(np.ones((2,3)),1,3,axis=1)\n    >>> xp\n    array([[ 0.,  1.,  1.,  1.,  0.,  0.,  0.],\n           [ 0.,  1.,  1.,  1.,  0.,  0.,  0.]])\n    >>> trimone(xp,1,3,1)\n    array([[ 1.,  1.,  1.],\n           [ 1.,  1.,  1.]])\n    ' #NEWLINE# shape = np . array ( x . shape ) #NEWLINE# shape [ axis ] -= ( axis + back ) #NEWLINE# shapearr = np . array ( x . shape ) #NEWLINE# startind = np . zeros ( x . ndim ) #NEWLINE# startind [ axis ] = front #NEWLINE# endind = ( startind + shape ) #NEWLINE# myslice = [ slice ( startind [ k ] , endind [ k ] ) for k in range ( len ( endind ) ) ] #NEWLINE# return x [ tuple ( myslice ) ]