def deconstruct_loop(dim):
    """A convenience function. Given a loop dimension, returns a tuple
    of (start, step, length). The opposite of expand_loop()."""
    length = len(dim)
    
    start = dim[0] if length else None
    
    step = (dim[1] - dim[0]) if (length > 1) else 0.0

    return start, step, length