def onedim_index(index, axis, ndim):
    """Return an index from a 1-dimensional index along the given axis
    
    >>> index = onedim_index(np.index_exp[1,2], 1, 3)
    >>> A=np.eye(3)
    >>> A[index]
    array([[ 0.,  0.],
           [ 1.,  0.],
           [ 0.,  1.]])
    
    """
    
    return (slice(None),) * (axis % ndim) + (index,)