diff tests/test_outliers.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 65b9330afdd8
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_outliers.py	Tue Sep 12 23:18:19 2017 +0100
@@ -0,0 +1,32 @@
+# -*- coding: utf-8 -*-
+"""
+Created on Fri Sep  1 19:11:52 2017
+
+@author: mariapanteli
+"""
+
+import pytest
+
+import numpy as np
+import pandas as pd
+
+import scripts.outliers as outliers
+
+
+def test_country_outlier_df():
+    counts = {'a':2, 'b':3}
+    labels = np.array(['a', 'a', 'a', 'a', 'b', 'b', 'b'])
+    df = outliers.country_outlier_df(counts, labels, normalize=True)
+    assert np.array_equal(df['Outliers'].get_values(), np.array([0.5, 1.0]))
+
+
+def test_normalize_outlier_counts():
+    outlier_counts = {'a':2, 'b':3}
+    country_counts = {'a':4, 'b':3}
+    outlier_counts = outliers.normalize_outlier_counts(outlier_counts, country_counts)
+    outlier_counts_true = {'a':.5, 'b':1.}
+    assert np.array_equal(outlier_counts, outlier_counts_true)
+
+
+def test_get_outliers_df():
+    assert True
\ No newline at end of file