def canonify_slice(s, n):
    """
    Convert a slice object into a canonical form
    to simplify treatment in histogram bin content
    and edge slicing.
    """
    if isinstance(s, (int, long)):
        return canonify_slice(slice(s, s + 1, None), n)
    start = s.start % n if s.start is not None else 0
    stop = s.stop % n if s.stop is not None else n
    step = s.step if s.step is not None else 1
    return slice(start, stop, step)
def canonify_slice ( s , n ) : if isinstance ( s , ( int , long ) ) : return canonify_slice ( slice ( s , s + 1 , None ) , n ) start = s . start % n if s . start is not None else 0 stop = s . stop % n if s . stop is not None else n step = s . step if s . step is not None else 1 return slice ( start , stop , step )
Convert a slice object into a canonical form
    to simplify treatment in histogram bin content
    and edge slicing.