From eaea0a3ed15b64eef3303128895b60279f440de2 Mon Sep 17 00:00:00 2001 From: Gertjan van den Burg Date: Tue, 15 Jan 2019 13:20:58 +0000 Subject: Add unit tests to git Oops --- test/test_util.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 test/test_util.py (limited to 'test/test_util.py') diff --git a/test/test_util.py b/test/test_util.py new file mode 100644 index 0000000..7a6f5bb --- /dev/null +++ b/test/test_util.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- + +""" + + Unit tests for the util module + +""" + +from __future__ import division, print_function + +import unittest + +from gensvm.util import get_ranks + + +class GenSVMUtilTestCase(unittest.TestCase): + def test_get_ranks(self): + """ UTIL: Test ranking function """ + x = [7, 0.1, 0.5, 0.1, 10, 100, 200] + self.assertEqual(get_ranks(x), [4, 1, 3, 1, 5, 6, 7]) + + x = [3, 3, 3] + self.assertEqual(get_ranks(x), [1, 1, 1]) + + x = [1, 2, 3] + self.assertEqual(get_ranks(x), [1, 2, 3]) + + x = [-1, -2, -3] + self.assertEqual(get_ranks(x), [3, 2, 1]) -- cgit v1.2.3