(path, segment_length)
return segment
Returns a segment sampled from a random place in a path. Returns None if the path is too short
Returns a segment sampled from a random place in a path. Returns None if the path is too short
Returns a segment sampled from a random place in a path . Returns None if the path is too short
def sample_segment_from_path(path, segment_length):
    """Returns a segment sampled from a random place in a path. Returns None if the path is too short"""
    path_length = len(path["obs"])
    if path_length < segment_length:
        return None

    start_pos = np.random.randint(0, path_length - segment_length + 1)

    # Build segment
    segment = _slice_path(path, segment_length, start_pos)

    # Add q_states
    segment["q_states"] = create_segment_q_states(segment)
    return segment
def sample_segment_from_path ( path , segment_length ) : path_length = len ( path [ "obs" ] ) if path_length < segment_length : return None start_pos = np . random . randint ( 0 , path_length - segment_length + 1 ) # Build segment segment = _slice_path ( path , segment_length , start_pos ) # Add q_states segment [ "q_states" ] = create_segment_q_states ( segment ) return segment