Mercurial > hg > plosone_underreview
view tests/test_map_and_average.py @ 30:e8084526f7e5 branch-tests
additional test functions
author | Maria Panteli <m.x.panteli@gmail.com> |
---|---|
date | Wed, 13 Sep 2017 19:57:49 +0100 |
parents | ed109218dd4b |
children | 4425a4918102 |
line wrap: on
line source
# -*- coding: utf-8 -*- """ Created on Fri Sep 1 19:11:52 2017 @author: mariapanteli """ import pytest import numpy as np import scripts.map_and_average as map_and_average def test_remove_inds(): labels = np.array(['a', 'a', 'b', 'unknown']) features = np.array([[0, 1], [0,2], [0, 3], [0, 4]]) audiolabels = np.array(['a', 'b', 'c', 'd']) features, labels, audiolabels = map_and_average.remove_inds(features, labels, audiolabels) assert len(features) == 3 and len(labels) == 3 and len(audiolabels) == 3 def test_remove_inds(): labels = np.array(['a', 'a', 'b', 'unknown']) features = np.array([[0, 1], [0,2], [0, 3], [0, 4]]) audiolabels = np.array(['a', 'b', 'c', 'd']) features, labels, audiolabels = map_and_average.remove_inds(features, labels, audiolabels) features_true = np.array([[0, 1], [0,2], [0, 3]]) assert np.array_equal(features, features_true) def test_averageframes(): classlabels = np.array(['a', 'a', 'b', 'b', 'b']) features = np.array([[0, 1], [0,2], [0, 1], [1, 1], [2, 1]]) audiolabels = np.array(['a', 'a', 'b', 'b', 'b']) feat, audio, labels = map_and_average.averageframes(features, audiolabels, classlabels) feat_true = np.array([[0, 1.5], [1, 1]]) assert np.array_equal(feat, feat_true)