aboutsummaryrefslogtreecommitdiff
path: root/test/test_util.py
diff options
context:
space:
mode:
authorGertjan van den Burg <gertjanvandenburg@gmail.com>2019-01-15 13:20:58 +0000
committerGertjan van den Burg <gertjanvandenburg@gmail.com>2019-01-15 13:20:58 +0000
commiteaea0a3ed15b64eef3303128895b60279f440de2 (patch)
tree9ecd3c155d479a0708b86ebc113e7cd677c4038b /test/test_util.py
parentFuture proof the cv argument (diff)
downloadpygensvm-eaea0a3ed15b64eef3303128895b60279f440de2.tar.gz
pygensvm-eaea0a3ed15b64eef3303128895b60279f440de2.zip
Add unit tests to git
Oops
Diffstat (limited to 'test/test_util.py')
-rw-r--r--test/test_util.py29
1 files changed, 29 insertions, 0 deletions
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])