Esempio n. 1
0
def load_sama(sama_path):
    """Load sama

    Args:
        sama_path (str): Local path where the sama annotation is stored.
            If `None`, returns None.

    Returns:
        SectionData: sama annotations

    """
    if sama_path is None:
        return None

    if not os.path.exists(sama_path):
        raise IOError("sama_path {} does not exist".format(sama_path))

    timestamps = []
    sama_cycles = []
    intervals = []
    with open(sama_path, 'r') as reader:
        for line in reader.readlines():
            timestamps.append(float(line))

    for i in np.arange(1, len(timestamps)):
        intervals.append([timestamps[i - 1], timestamps[i]])
        sama_cycles.append('sama cycle ' + str(i))

    if not intervals:
        return None

    return utils.SectionData(np.array(intervals), sama_cycles)
Esempio n. 2
0
def load_sections(sections_path):
    """Load Beatles format section data from a file

    Args:
        sections_path (str): path to section annotation file

    Returns:
        (utils.SectionData): loaded section data

    """
    if sections_path is None:
        return None

    if not os.path.exists(sections_path):
        raise IOError("sections_path {} does not exist".format(sections_path))

    start_times, end_times, sections = [], [], []
    with open(sections_path, "r") as fhandle:
        reader = csv.reader(fhandle, delimiter="\t")
        for line in reader:
            start_times.append(float(line[0]))
            end_times.append(float(line[1]))
            sections.append(line[3])

    section_data = utils.SectionData(
        np.array([start_times, end_times]).T, sections)

    return section_data
Esempio n. 3
0
def load_sections(sections_path, iam_style):
    """Load sections from carnatic collection

    Args:
        sections_path (str): Local path where the section annotation is stored.
        iam_style (str): Flag to differentiate between hindustani and carnatic tracks

    Returns:
        SectionData: section annotations for track

    """
    if sections_path is None:
        return None

    if not os.path.exists(sections_path):
        raise IOError("sections_path {} does not exist".format(sections_path))

    intervals = []
    section_labels = []
    if iam_style == 'carnatic':
        with open(sections_path, 'r') as reader:
            for line in reader.readlines():
                if line != '\n':
                    intervals.append([
                        float(line.split('\t')[0]),
                        float(line.split('\t')[0]) +
                        float(line.split('\t')[2]),
                    ])
                    section_labels.append(
                        str(line.split('\t')[3].split('\n')[0]))

        if not intervals:
            return None

    if iam_style == 'hindustani':
        with open(sections_path, 'r') as reader:
            for line in reader.readlines():
                if line != '\n':
                    intervals.append([
                        float(line.split(',')[0]),
                        float(line.split(',')[0]) + float(line.split(',')[2]),
                    ])
                    section_labels.append(
                        str(line.split(',')[3].split('\n')[0]) + '-' +
                        str(line.split(',')[1]))

        if not intervals:
            return None

    return utils.SectionData(np.array(intervals), section_labels)
Esempio n. 4
0
def _load_sections(sections_path):
    if not os.path.exists(sections_path):
        return None
    begs = []  # timestamps of section beginnings
    ends = []  # timestamps of section endings
    secs = []  # section labels

    with open(sections_path, 'r') as fhandle:
        reader = csv.reader(fhandle, delimiter='\t')
        for line in reader:
            begs.append(float(line[0]) / 100.0)
            ends.append(float(line[1]) / 100.0)
            secs.append(line[2])

    return utils.SectionData(np.array(begs), np.array(ends), np.array(secs))
Esempio n. 5
0
def load_sections(sections_path):
    if not os.path.exists(sections_path):
        raise IOError("sections_path {} does not exist".format(sections_path))

    begs = []  # timestamps of section beginnings
    ends = []  # timestamps of section endings
    secs = []  # section labels

    with open(sections_path, 'r') as fhandle:
        reader = csv.reader(fhandle, delimiter='\t')
        for line in reader:
            begs.append(float(line[0]) / 100.0)
            ends.append(float(line[1]) / 100.0)
            secs.append(line[2])

    return utils.SectionData(np.array([begs, ends]).T, secs)
Esempio n. 6
0
def load_sections(sections_path):
    if sections_path is None or not os.path.exists(sections_path):
        return None

    times = []
    secs = []
    with open(sections_path, 'r') as fhandle:
        reader = csv.reader(fhandle, delimiter='\t')
        for line in reader:
            times.append(float(line[0]))
            secs.append(line[1])
    times = np.array(times)
    secs = np.array(secs)

    # remove sections with length == 0
    times_revised = np.delete(times, np.where(np.diff(times) == 0))
    secs_revised = np.delete(secs, np.where(np.diff(times) == 0))
    return utils.SectionData(
        np.array([times_revised[:-1], times_revised[1:]]).T,
        list(secs_revised[:-1]))
Esempio n. 7
0
def _load_sections(sections_path):
    """Private function to load Beatles format sections data from a file

    Args:
        sections_path (str):

    """
    if sections_path is None or not os.path.exists(sections_path):
        return None

    start_times, end_times, sections = [], [], []
    with open(sections_path, 'r') as fhandle:
        reader = csv.reader(fhandle, delimiter='\t')
        for line in reader:
            start_times.append(float(line[0]))
            end_times.append(float(line[1]))
            sections.append(line[3])

    section_data = utils.SectionData(np.array([start_times, end_times]).T, sections)

    return section_data
Esempio n. 8
0
def test_multi_sections():
    multi_section_data_1 = [
        (
            [
                (
                    utils.SectionData(
                        np.array([[0.0, 10.0, 20.0], [10.0, 20.0, 25.0]]).T,
                        np.array(["verse A", "verse B", "verse A"]),
                    ),
                    None,
                ),
                (
                    utils.SectionData(
                        np.array([[0.0, 15.0, 20.0], [15.0, 20.0, 25.0]]).T,
                        np.array(["verse a", "verse b", "verse a"]),
                    ),
                    None,
                ),
            ],
            None,
        )
    ]

    multi_section_data_2 = [
        (
            [
                (
                    utils.SectionData(
                        np.array([[0.0, 10.0, 20.0], [10.0, 20.0, 25.0]]).T,
                        np.array(["verse A", "verse B", "verse A"]),
                    ),
                    0,
                ),
                (
                    utils.SectionData(
                        np.array([[0.0, 15.0, 20.0], [15.0, 20.0, 25.0]]).T,
                        np.array(["verse a", "verse b", "verse a"]),
                    ),
                    1,
                ),
            ],
            "annotator_1",
        )
    ]
    multi_section_data_3 = [
        (
            [
                (
                    utils.SectionData(
                        np.array([[0.0, 10.0, 20.0], [10.0, 20.0, 25.0]]).T,
                        np.array(["verse A", "verse B", "verse A"]),
                    ),
                    0,
                ),
                (
                    utils.SectionData(
                        np.array([[0.0, 15.0, 20.0], [15.0, 20.0, 25.0]]).T,
                        np.array(["verse a", "verse b", "verse a"]),
                    ),
                    1,
                ),
            ],
            "annotator_1",
        ),
        (
            [
                (
                    utils.SectionData(
                        np.array([[0.0, 10.0, 20.0], [10.0, 20.0, 25.0]]).T,
                        np.array(["verse A", "verse B", "verse A"]),
                    ),
                    0,
                ),
                (
                    utils.SectionData(
                        np.array([[0.0, 15.0, 20.0], [15.0, 20.0, 25.0]]).T,
                        np.array(["verse a", "verse b", "verse a"]),
                    ),
                    1,
                ),
            ],
            "annotator_2",
        ),
    ]
    multi_section_data_4 = (
        [
            (
                utils.SectionData(
                    np.array([[0.0, 10.0, 20.0], [10.0, 20.0, 25.0]]).T,
                    np.array(["verse A", "verse B", "verse A"]),
                ),
                None,
            ),
            (
                utils.SectionData(
                    np.array([[0.0, 15.0, 20.0], [15.0, 20.0, 25.0]]).T,
                    np.array(["verse a", "verse b", "verse a"]),
                ),
                None,
            ),
        ],
        None,
    )
    multi_section_data_5 = [
        [
            [
                (
                    utils.SectionData(
                        np.array([[0.0, 10.0, 20.0], [10.0, 20.0, 25.0]]).T,
                        np.array(["verse A", "verse B", "verse A"]),
                    ),
                    None,
                ),
                (
                    utils.SectionData(
                        np.array([[0.0, 15.0, 20.0], [15.0, 20.0, 25.0]]).T,
                        np.array(["verse a", "verse b", "verse a"]),
                    ),
                    None,
                ),
            ],
            None,
        ]
    ]
    multi_section_data_6 = [
        (
            (
                (
                    utils.SectionData(
                        np.array([[0.0, 10.0, 20.0], [10.0, 20.0, 25.0]]).T,
                        np.array(["verse A", "verse B", "verse A"]),
                    ),
                    None,
                ),
                (
                    utils.SectionData(
                        np.array([[0.0, 15.0, 20.0], [15.0, 20.0, 25.0]]).T,
                        np.array(["verse a", "verse b", "verse a"]),
                    ),
                    None,
                ),
            ),
            None,
        )
    ]
    multi_section_data_7 = [([(None, None), (None, None)], None)]
    multi_section_data_8 = [
        (
            [
                (
                    utils.EventData(
                        np.array([0.2, 0.3]),
                        np.array([0.3, 0.4]),
                        np.array(["event A", "event B"]),
                    ),
                    None,
                ),
                (
                    utils.EventData(
                        np.array([0.2, 0.3]),
                        np.array([0.3, 0.4]),
                        np.array(["event A", "event B"]),
                    ),
                    None,
                ),
            ],
            None,
        )
    ]

    jam_1 = jams_utils.jams_converter(multi_section_data=multi_section_data_1)
    jam_2 = jams_utils.jams_converter(multi_section_data=multi_section_data_2)
    jam_3 = jams_utils.jams_converter(multi_section_data=multi_section_data_3)
    jam_7 = jams_utils.jams_converter(multi_section_data=multi_section_data_7)

    time, duration, value, confidence = get_jam_data(jam_1, "multi_segment", 0)
    assert time == [0.0, 0.0, 10.0, 15.0, 20.0, 20.0]
    assert duration == [10.0, 15.0, 10.0, 5.0, 5.0, 5.0]
    assert value == [
        {"label": "verse A", "level": None},
        {"label": "verse a", "level": None},
        {"label": "verse B", "level": None},
        {"label": "verse b", "level": None},
        {"label": "verse A", "level": None},
        {"label": "verse a", "level": None},
    ]
    assert confidence == [None, None, None, None, None, None]

    assert (
        jam_2.annotations[0]["annotation_metadata"]["annotator"]["name"]
        == "annotator_1"
    )

    time, duration, value, confidence = get_jam_data(jam_3, "multi_segment", 0)
    assert time == [0.0, 0.0, 10.0, 15.0, 20.0, 20.0]
    assert duration == [10.0, 15.0, 10.0, 5.0, 5.0, 5.0]
    assert value == [
        {"label": "verse A", "level": 0},
        {"label": "verse a", "level": 1},
        {"label": "verse B", "level": 0},
        {"label": "verse b", "level": 1},
        {"label": "verse A", "level": 0},
        {"label": "verse a", "level": 1},
    ]
    assert confidence == [None, None, None, None, None, None]

    time, duration, value, confidence = get_jam_data(jam_3, "multi_segment", 1)
    assert time == [0.0, 0.0, 10.0, 15.0, 20.0, 20.0]
    assert duration == [10.0, 15.0, 10.0, 5.0, 5.0, 5.0]
    assert value == [
        {"label": "verse A", "level": 0},
        {"label": "verse a", "level": 1},
        {"label": "verse B", "level": 0},
        {"label": "verse b", "level": 1},
        {"label": "verse A", "level": 0},
        {"label": "verse a", "level": 1},
    ]
    assert confidence == [None, None, None, None, None, None]

    time, duration, value, confidence = get_jam_data(jam_7, "multi_segment", 0)
    assert time == []
    assert duration == []
    assert value == []
    assert confidence == []

    assert type(jam_1) == jams.JAMS

    with pytest.raises(TypeError):
        jams_utils.jams_converter(multi_section_data=multi_section_data_4)
    with pytest.raises(TypeError):
        jams_utils.jams_converter(multi_section_data=multi_section_data_5)
    with pytest.raises(TypeError):
        jams_utils.jams_converter(multi_section_data=multi_section_data_6)
    with pytest.raises(TypeError):
        jams_utils.jams_converter(multi_section_data=multi_section_data_8)
Esempio n. 9
0
def test_sections():
    section_data_1 = [
        (
            utils.SectionData(
                np.array([[0.0, 10.0, 20.0], [10.0, 20.0, 25.0]]).T,
                np.array(["verse A", "verse B", "verse A"]),
            ),
            None,
        )
    ]
    section_data_2 = [
        (
            utils.SectionData(
                np.array([[0.0, 10.0, 20.0], [10.0, 20.0, 25.0]]).T,
                np.array(["verse A", "verse B", "verse A"]),
            ),
            "sections_2",
        )
    ]
    section_data_3 = [
        (
            utils.SectionData(
                np.array([[0.0, 10.0, 20.0], [10.0, 20.0, 25.0]]).T,
                np.array(["verse A", "verse B", "verse A"]),
            ),
            "sections_1",
        ),
        (
            utils.SectionData(
                np.array([[0.0, 15.0, 20.0], [15.0, 20.0, 30.0]]).T,
                np.array(["verse A", "verse B", "verse C"]),
            ),
            "sections_2",
        ),
    ]
    section_data_4 = (
        utils.SectionData(
            np.array([[0.0, 10.0, 20.0], [10.0, 20.0, 25.0]]).T,
            np.array(["verse A", "verse B", "verse A"]),
        ),
        None,
    )
    section_data_5 = [
        [
            utils.SectionData(
                np.array([[0.0, 10.0, 20.0], [10.0, 20.0, 25.0]]).T,
                np.array(["verse A", "verse B", "verse A"]),
            ),
            None,
        ],
        (
            utils.SectionData(
                np.array([[0.0, 10.0, 20.0], [10.0, 20.0, 25.0]]).T,
                np.array(["verse A", "verse B", "verse A"]),
            ),
            "sections_2",
        ),
    ]
    section_data_6 = [(None, None)]
    section_data_7 = [
        (
            utils.EventData(
                np.array([0.2, 0.3]),
                np.array([0.3, 0.4]),
                np.array(["event A", "event B"]),
            ),
            None,
        )
    ]

    jam_1 = jams_utils.jams_converter(section_data=section_data_1)
    jam_2 = jams_utils.jams_converter(section_data=section_data_2)
    jam_3 = jams_utils.jams_converter(section_data=section_data_3)
    jam_6 = jams_utils.jams_converter(section_data=section_data_6)

    time, duration, value, confidence = get_jam_data(jam_1, "segment", 0)
    assert time == [0.0, 10.0, 20.0]
    assert duration == [10.0, 10.0, 5.0]
    assert value == ["verse A", "verse B", "verse A"]
    assert confidence == [None, None, None]

    assert jam_2.annotations[0]["sandbox"]["name"] == "sections_2"

    time, duration, value, confidence = get_jam_data(jam_3, "segment", 0)
    assert time == [0.0, 10.0, 20.0]
    assert duration == [10.0, 10.0, 5.0]
    assert value == ["verse A", "verse B", "verse A"]
    assert confidence == [None, None, None]

    time, duration, value, confidence = get_jam_data(jam_3, "segment", 1)
    assert time == [0.0, 15.0, 20.0]
    assert duration == [15.0, 5.0, 10.0]
    assert value == ["verse A", "verse B", "verse C"]
    assert confidence == [None, None, None]

    time, duration, value, confidence = get_jam_data(jam_6, "segment", 0)
    assert time == []
    assert duration == []
    assert value == []
    assert confidence == []

    assert type(jam_1) == jams.JAMS

    with pytest.raises(TypeError):
        jams_utils.jams_converter(section_data=section_data_4)
    with pytest.raises(TypeError):
        jams_utils.jams_converter(section_data=section_data_5)
    with pytest.raises(TypeError):
        jams_utils.jams_converter(section_data=section_data_7)
Esempio n. 10
0
def test_multi_sections():
    multi_section_data_1 = [
        (
            [
                (
                    utils.SectionData(
                        np.array([[0.0, 10.0, 20.0], [10.0, 20.0, 25.0]]).T,
                        np.array(['verse A', 'verse B', 'verse A']),
                    ),
                    None,
                ),
                (
                    utils.SectionData(
                        np.array([[0.0, 15.0, 20.0], [15.0, 20.0, 25.0]]).T,
                        np.array(['verse a', 'verse b', 'verse a']),
                    ),
                    None,
                ),
            ],
            None,
        )
    ]

    multi_section_data_2 = [
        (
            [
                (
                    utils.SectionData(
                        np.array([[0.0, 10.0, 20.0], [10.0, 20.0, 25.0]]).T,
                        np.array(['verse A', 'verse B', 'verse A']),
                    ),
                    0,
                ),
                (
                    utils.SectionData(
                        np.array([[0.0, 15.0, 20.0], [15.0, 20.0, 25.0]]).T,
                        np.array(['verse a', 'verse b', 'verse a']),
                    ),
                    1,
                ),
            ],
            'annotator_1',
        )
    ]
    multi_section_data_3 = [
        (
            [
                (
                    utils.SectionData(
                        np.array([[0.0, 10.0, 20.0], [10.0, 20.0, 25.0]]).T,
                        np.array(['verse A', 'verse B', 'verse A']),
                    ),
                    0,
                ),
                (
                    utils.SectionData(
                        np.array([[0.0, 15.0, 20.0], [15.0, 20.0, 25.0]]).T,
                        np.array(['verse a', 'verse b', 'verse a']),
                    ),
                    1,
                ),
            ],
            'annotator_1',
        ),
        (
            [
                (
                    utils.SectionData(
                        np.array([[0.0, 10.0, 20.0], [10.0, 20.0, 25.0]]).T,
                        np.array(['verse A', 'verse B', 'verse A']),
                    ),
                    0,
                ),
                (
                    utils.SectionData(
                        np.array([[0.0, 15.0, 20.0], [15.0, 20.0, 25.0]]).T,
                        np.array(['verse a', 'verse b', 'verse a']),
                    ),
                    1,
                ),
            ],
            'annotator_2',
        ),
    ]
    multi_section_data_4 = (
        [
            (
                utils.SectionData(
                    np.array([[0.0, 10.0, 20.0], [10.0, 20.0, 25.0]]).T,
                    np.array(['verse A', 'verse B', 'verse A']),
                ),
                None,
            ),
            (
                utils.SectionData(
                    np.array([[0.0, 15.0, 20.0], [15.0, 20.0, 25.0]]).T,
                    np.array(['verse a', 'verse b', 'verse a']),
                ),
                None,
            ),
        ],
        None,
    )
    multi_section_data_5 = [
        [
            [
                (
                    utils.SectionData(
                        np.array([[0.0, 10.0, 20.0], [10.0, 20.0, 25.0]]).T,
                        np.array(['verse A', 'verse B', 'verse A']),
                    ),
                    None,
                ),
                (
                    utils.SectionData(
                        np.array([[0.0, 15.0, 20.0], [15.0, 20.0, 25.0]]).T,
                        np.array(['verse a', 'verse b', 'verse a']),
                    ),
                    None,
                ),
            ],
            None,
        ]
    ]
    multi_section_data_6 = [
        (
            (
                (
                    utils.SectionData(
                        np.array([[0.0, 10.0, 20.0], [10.0, 20.0, 25.0]]).T,
                        np.array(['verse A', 'verse B', 'verse A']),
                    ),
                    None,
                ),
                (
                    utils.SectionData(
                        np.array([[0.0, 15.0, 20.0], [15.0, 20.0, 25.0]]).T,
                        np.array(['verse a', 'verse b', 'verse a']),
                    ),
                    None,
                ),
            ),
            None,
        )
    ]
    multi_section_data_7 = [([(None, None), (None, None)], None)]
    multi_section_data_8 = [
        (
            [
                (
                    utils.EventData(
                        np.array([0.2, 0.3]),
                        np.array([0.3, 0.4]),
                        np.array(['event A', 'event B']),
                    ),
                    None,
                ),
                (
                    utils.EventData(
                        np.array([0.2, 0.3]),
                        np.array([0.3, 0.4]),
                        np.array(['event A', 'event B']),
                    ),
                    None,
                ),
            ],
            None,
        )
    ]

    jam_1 = jams_utils.jams_converter(multi_section_data=multi_section_data_1)
    jam_2 = jams_utils.jams_converter(multi_section_data=multi_section_data_2)
    jam_3 = jams_utils.jams_converter(multi_section_data=multi_section_data_3)
    jam_7 = jams_utils.jams_converter(multi_section_data=multi_section_data_7)

    time, duration, value, confidence = get_jam_data(jam_1, 'multi_segment', 0)
    assert time == [0.0, 0.0, 10.0, 15.0, 20.0, 20.0]
    assert duration == [10.0, 15.0, 10.0, 5.0, 5.0, 5.0]
    assert value == [
        {'label': 'verse A', 'level': None},
        {'label': 'verse a', 'level': None},
        {'label': 'verse B', 'level': None},
        {'label': 'verse b', 'level': None},
        {'label': 'verse A', 'level': None},
        {'label': 'verse a', 'level': None},
    ]
    assert confidence == [None, None, None, None, None, None]

    assert (
        jam_2.annotations[0]['annotation_metadata']['annotator']['name']
        == 'annotator_1'
    )

    time, duration, value, confidence = get_jam_data(jam_3, 'multi_segment', 0)
    assert time == [0.0, 0.0, 10.0, 15.0, 20.0, 20.0]
    assert duration == [10.0, 15.0, 10.0, 5.0, 5.0, 5.0]
    assert value == [
        {'label': 'verse A', 'level': 0},
        {'label': 'verse a', 'level': 1},
        {'label': 'verse B', 'level': 0},
        {'label': 'verse b', 'level': 1},
        {'label': 'verse A', 'level': 0},
        {'label': 'verse a', 'level': 1},
    ]
    assert confidence == [None, None, None, None, None, None]

    time, duration, value, confidence = get_jam_data(jam_3, 'multi_segment', 1)
    assert time == [0.0, 0.0, 10.0, 15.0, 20.0, 20.0]
    assert duration == [10.0, 15.0, 10.0, 5.0, 5.0, 5.0]
    assert value == [
        {'label': 'verse A', 'level': 0},
        {'label': 'verse a', 'level': 1},
        {'label': 'verse B', 'level': 0},
        {'label': 'verse b', 'level': 1},
        {'label': 'verse A', 'level': 0},
        {'label': 'verse a', 'level': 1},
    ]
    assert confidence == [None, None, None, None, None, None]

    time, duration, value, confidence = get_jam_data(jam_7, 'multi_segment', 0)
    assert time == []
    assert duration == []
    assert value == []
    assert confidence == []

    assert type(jam_1) == jams.JAMS

    with pytest.raises(TypeError):
        jams_utils.jams_converter(multi_section_data=multi_section_data_4)
    with pytest.raises(TypeError):
        jams_utils.jams_converter(multi_section_data=multi_section_data_5)
    with pytest.raises(TypeError):
        jams_utils.jams_converter(multi_section_data=multi_section_data_6)
    with pytest.raises(TypeError):
        jams_utils.jams_converter(multi_section_data=multi_section_data_8)
Esempio n. 11
0
def test_sections():
    section_data_1 = [
        (
            utils.SectionData(
                np.array([[0.0, 10.0, 20.0], [10.0, 20.0, 25.0]]).T,
                np.array(['verse A', 'verse B', 'verse A']),
            ),
            None,
        )
    ]
    section_data_2 = [
        (
            utils.SectionData(
                np.array([[0.0, 10.0, 20.0], [10.0, 20.0, 25.0]]).T,
                np.array(['verse A', 'verse B', 'verse A']),
            ),
            'sections_2',
        )
    ]
    section_data_3 = [
        (
            utils.SectionData(
                np.array([[0.0, 10.0, 20.0], [10.0, 20.0, 25.0]]).T,
                np.array(['verse A', 'verse B', 'verse A']),
            ),
            'sections_1',
        ),
        (
            utils.SectionData(
                np.array([[0.0, 15.0, 20.0], [15.0, 20.0, 30.0]]).T,
                np.array(['verse A', 'verse B', 'verse C']),
            ),
            'sections_2',
        ),
    ]
    section_data_4 = (
        utils.SectionData(
            np.array([[0.0, 10.0, 20.0], [10.0, 20.0, 25.0]]).T,
            np.array(['verse A', 'verse B', 'verse A']),
        ),
        None,
    )
    section_data_5 = [
        [
            utils.SectionData(
                np.array([[0.0, 10.0, 20.0], [10.0, 20.0, 25.0]]).T,
                np.array(['verse A', 'verse B', 'verse A']),
            ),
            None,
        ],
        (
            utils.SectionData(
                np.array([[0.0, 10.0, 20.0], [10.0, 20.0, 25.0]]).T,
                np.array(['verse A', 'verse B', 'verse A']),
            ),
            'sections_2',
        ),
    ]
    section_data_6 = [(None, None)]
    section_data_7 = [
        (
            utils.EventData(
                np.array([0.2, 0.3]),
                np.array([0.3, 0.4]),
                np.array(['event A', 'event B']),
            ),
            None,
        )
    ]

    jam_1 = jams_utils.jams_converter(section_data=section_data_1)
    jam_2 = jams_utils.jams_converter(section_data=section_data_2)
    jam_3 = jams_utils.jams_converter(section_data=section_data_3)
    jam_6 = jams_utils.jams_converter(section_data=section_data_6)

    time, duration, value, confidence = get_jam_data(jam_1, 'segment', 0)
    assert time == [0.0, 10.0, 20.0]
    assert duration == [10.0, 10.0, 5.0]
    assert value == ['verse A', 'verse B', 'verse A']
    assert confidence == [None, None, None]

    assert jam_2.annotations[0]['sandbox']['name'] == 'sections_2'

    time, duration, value, confidence = get_jam_data(jam_3, 'segment', 0)
    assert time == [0.0, 10.0, 20.0]
    assert duration == [10.0, 10.0, 5.0]
    assert value == ['verse A', 'verse B', 'verse A']
    assert confidence == [None, None, None]

    time, duration, value, confidence = get_jam_data(jam_3, 'segment', 1)
    assert time == [0.0, 15.0, 20.0]
    assert duration == [15.0, 5.0, 10.0]
    assert value == ['verse A', 'verse B', 'verse C']
    assert confidence == [None, None, None]

    time, duration, value, confidence = get_jam_data(jam_6, 'segment', 0)
    assert time == []
    assert duration == []
    assert value == []
    assert confidence == []

    assert type(jam_1) == jams.JAMS

    with pytest.raises(TypeError):
        jams_utils.jams_converter(section_data=section_data_4)
    with pytest.raises(TypeError):
        jams_utils.jams_converter(section_data=section_data_5)
    with pytest.raises(TypeError):
        jams_utils.jams_converter(section_data=section_data_7)