MCPcopy Create free account
hub / github.com/chaimleib/intervaltree / OptimalityTestMatrix

Class OptimalityTestMatrix

test/optimality/optimality_test_matrix.py:34–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32
33
34class OptimalityTestMatrix(object):
35 def __init__(self, ivs=None, verbose=False):
36 """
37 Initilize a test matrix. To run it, see run().
38 :param ivs: A dictionary mapping each test name to its
39 iterable of Intervals.
40 :type ivs: None or dict of [str, list of Interval]
41 :param verbose: Whether to print the structure of the trees
42 :type verbose: bool
43 """
44 self.verbose = verbose
45
46 # set test_tupes
47 self.test_types = {}
48 # all methods beginning with "test_"
49 test_names = [
50 name for name in self.__class__.__dict__
51 if
52 callable(getattr(self, name)) and
53 name.startswith('test_')
54 ]
55 for test_name in test_names:
56 key = test_name[len('test_'):]
57 key = ' '.join(key.split('_'))
58 test_function = getattr(self, test_name)
59 self.test_types[key] = test_function
60
61 # set ivs
62 self.ivs = {
63 key: [Interval(*tup) for tup in value.data]
64 for key, value in data.__dict__.items()
65 if 'copy_structure' not in key and hasattr(value, 'data')
66 }
67
68 # initialize result matrix
69 self.result_matrix = {
70 'ivs name': {},
71 'test type': {}
72 }
73 for name in self.ivs:
74 self.result_matrix['ivs name'][name] = {}
75 for name in self.test_types:
76 self.result_matrix['test type'][name] = {}
77 self.summary_matrix = deepcopy(self.result_matrix)
78
79 def test_init(self, ivs):
80 t = IntervalTree(ivs)
81 return t
82
83 def test_add_ascending(self, ivs):
84 if self.verbose:
85 pbar = ProgressBar(len(ivs))
86 t = IntervalTree()
87 for iv in sorted(ivs):
88 t.add(iv)
89 if self.verbose: pbar()
90 return t
91

Callers 3

optimality_test.pyFile · 0.90
optimality_coreFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…