def axis_slicer(n, sl, axis):
    """
    Return an indexing tuple for an array with `n` dimensions,
    with slice `sl` taken on `axis`.
    """
    itup = [slice(None)] * n
    itup[axis] = sl
    return tuple(itup)
