def idx_range(idx, radius, length):
    """
    given an idx, a radius and a maximum length, returns starting and ending
    indices of a a window centered at that idx and having that radius, without
    indices > length nor < 0
    """
    return max(0, idx - radius), min(length, idx + radius + 1)