/
test_make_tables.py
82 lines (65 loc) · 2.24 KB
/
test_make_tables.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env python
#-----------------------------------------------------------------------------
# Copyright (c) 2011-2013, The BIOM Format Development Team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
from biom.unit_test import TestCase, main
from make_tables import n_nonzero_items, get_next_row_index, get_next_col_index
class MakeTablesTests(TestCase):
def setUp(self):
pass
def test_n_nonzero_items(self):
"""Determine the number of non zero items to populate"""
n = 10
m = 100
p = 0.01
exp = 10
obs = n_nonzero_items(n,m,p)
self.assertEqual(obs, exp)
def test_get_next_row_index(self):
"""Determine the next row index"""
n = 10
cur_row = 1
exp_row = 2
obs_row = get_next_row_index(n, cur_row)
self.assertEqual(obs_row, exp_row)
cur_row = 0
exp_row = 1
obs_row = get_next_row_index(n, cur_row)
self.assertEqual(obs_row, exp_row)
cur_row = 8
exp_row = 9
obs_row = get_next_row_index(n,cur_row)
self.assertEqual(obs_row, exp_row)
cur_row = 9 # n = 10, idx of 9 is max row
exp_row = 7
obs_row = get_next_row_index(n,cur_row)
self.assertEqual(obs_row, exp_row)
cur_row = 1
exp_row = 0
obs_row = get_next_row_index(n, cur_row)
self.assertEqual(obs_row, exp_row)
def test_get_next_col_index(self):
"""determine the next col index"""
m = 100
cur_col = 98
exp_col = 99
obs_col = get_next_col_index(m, cur_col)
self.assertEqual(obs_col, exp_col)
cur_col = 99
exp_col = 98
obs_col = get_next_col_index(m, cur_col)
self.assertEqual(obs_col, exp_col)
cur_col = 1
exp_col = 0
obs_col = get_next_col_index(m, cur_col)
self.assertEqual(obs_col, exp_col)
cur_col = 0
exp_col = 1
obs_col = get_next_col_index(m, cur_col)
self.assertEqual(obs_col, exp_col)
if __name__ == '__main__':
main()