Mercurial > hg > plosone_underreview
comparison tests/test_map_and_average.py @ 18:ed109218dd4b branch-tests
rename result scripts and more tests
author | Maria Panteli |
---|---|
date | Tue, 12 Sep 2017 23:18:19 +0100 |
parents | |
children | e8084526f7e5 |
comparison
equal
deleted
inserted
replaced
17:2e487b9c0a7b | 18:ed109218dd4b |
---|---|
1 # -*- coding: utf-8 -*- | |
2 """ | |
3 Created on Fri Sep 1 19:11:52 2017 | |
4 | |
5 @author: mariapanteli | |
6 """ | |
7 | |
8 import pytest | |
9 | |
10 import numpy as np | |
11 | |
12 import scripts.map_and_average as map_and_average | |
13 | |
14 | |
15 def test_remove_inds(): | |
16 labels = np.array(['a', 'a', 'b', 'unknown']) | |
17 features = np.array([[0, 1], [0,2], [0, 3], [0, 4]]) | |
18 audiolabels = np.array(['a', 'b', 'c', 'd']) | |
19 features, labels, audiolabels = map_and_average.remove_inds(features, labels, audiolabels) | |
20 assert len(features) == 3 and len(labels) == 3 and len(audiolabels) == 3 | |
21 | |
22 | |
23 def test_remove_inds(): | |
24 labels = np.array(['a', 'a', 'b', 'unknown']) | |
25 features = np.array([[0, 1], [0,2], [0, 3], [0, 4]]) | |
26 audiolabels = np.array(['a', 'b', 'c', 'd']) | |
27 features, labels, audiolabels = map_and_average.remove_inds(features, labels, audiolabels) | |
28 features_true = np.array([[0, 1], [0,2], [0, 3]]) | |
29 assert np.array_equal(features, features_true) | |
30 | |
31 | |
32 def test_averageframes(): | |
33 classlabels = np.array(['a', 'a', 'b', 'b', 'b']) | |
34 features = np.array([[0, 1], [0,2], [0, 1], [1, 1], [2, 1]]) | |
35 audiolabels = np.array(['a', 'a', 'b', 'b', 'b']) | |
36 feat, audio, labels = map_and_average.averageframes(features, audiolabels, classlabels) | |
37 feat_true = np.array([[0, 0.5], [1, 1]]) |