def get_non_negative_index(index, length):
    """
    Converts negative indices to positive ones
    """
    while index < 0:
        if length > 0:
            index += length
        else:
            index = 0
    return index
