annotate tests/test_unique.py @ 80:3c7927f59b05

notes to self re deep neural networks
author Jeff Hammel <k0scist@gmail.com>
date Sun, 17 Dec 2017 13:43:42 -0800
parents 9d55e0299c3f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
50
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
1 #!/usr/bin/env python
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
2
51
e1eb45c4763e [compat] fix variable scoping for py3
Jeff Hammel <k0scist@gmail.com>
parents: 50
diff changeset
3 """
e1eb45c4763e [compat] fix variable scoping for py3
Jeff Hammel <k0scist@gmail.com>
parents: 50
diff changeset
4 test uniqueness of set elements
e1eb45c4763e [compat] fix variable scoping for py3
Jeff Hammel <k0scist@gmail.com>
parents: 50
diff changeset
5 """
e1eb45c4763e [compat] fix variable scoping for py3
Jeff Hammel <k0scist@gmail.com>
parents: 50
diff changeset
6
50
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
7 import os
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
8 import unittest
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
9 from tvii.unique import unique
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
10 from tvii.unique import NotUnique
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
11
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
12 class TestUnique(unittest.TestCase):
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
13
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
14 def test_positive(self):
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
15 """ensure the unique functionality works as expected"""
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
16
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
17 # true positive
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
18 a_unique_value = [7] * 7
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
19 assert unique(a_unique_value) == 7
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
20
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
21 def test_negative(self):
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
22 """what if a set is not unique?"""
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
23
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
24 data = [1,2,3,4]
68
5916b04d0582 update uniqueness test
Jeff Hammel <k0scist@gmail.com>
parents: 51
diff changeset
25 e = None
50
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
26 try:
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
27 unique(data)
71
9d55e0299c3f fix scoping for python 3.6
Jeff Hammel <k0scist@gmail.com>
parents: 68
diff changeset
28 except NotUnique as _e:
9d55e0299c3f fix scoping for python 3.6
Jeff Hammel <k0scist@gmail.com>
parents: 68
diff changeset
29 e = _e
68
5916b04d0582 update uniqueness test
Jeff Hammel <k0scist@gmail.com>
parents: 51
diff changeset
30 assert e is not None
5916b04d0582 update uniqueness test
Jeff Hammel <k0scist@gmail.com>
parents: 51
diff changeset
31 assert isinstance(e, NotUnique)
50
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
32
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
33 if __name__ == '__main__':
4b20694b8a16 add module + test for uniqueness
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
34 unittest.main()