Exemplo n.º 1
0
def test_labels_to_indices():
    """Test if the label to index converter works as expected."""
    dataloader = DummyLoader(classes=[
        'mood/theme---a',
        'mood/theme---b',
        'mood/theme---c',
        'mood/theme---d',
        'mood/theme---e',
        'mood/theme---f',
        'mood/theme---g',
        'mood/theme---h',
    ])

    label_list = ['b', 'e', 'mood/theme---f', 'a', 'mood/theme---c']
    expected = [1, 4, 5, 0, 2]

    actual = labels_to_indices(dataloader=dataloader, label_list=label_list)

    assert (expected == actual).all()
 labels_to_indices(
     dataloader=dataloader,
     label_list=[  # theme
         'action',
         'adventure',
         'advertising',
         'background',
         'ballad',
         'children',
         'christmas',
         'commercial',
         'corporate',
         'documentary',
         'drama',
         'dream',
         'film',
         'game',
         'holiday',
         'love',
         'movie',
         'nature',
         'party',
         'retro',
         'soundscape',
         'space',
         'sport',
         'summer',
         'trailer',
         'travel',
     ],
 ),