def axis_slice(a, start=None, stop=None, step=None, axis=(-1)):
 a_slice = ([slice(None)] * a.ndim)
 a_slice[axis] = slice(start, stop, step)
 b = a[a_slice]
 return b

def axis_slice ( a , start = None , stop = None , step = None , axis = ( - 1 ) ) : a_slice = ( [ slice ( None ) ] * a . ndim ) a_slice [ axis ] = slice ( start , stop , step ) b = a [ a_slice ] return b
take a slice along axis axis from a .