view 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
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, 0.5], [1, 1]])