|
|
|
@ -31,14 +31,14 @@ class TestStructureEstimator(unittest.TestCase): |
|
|
|
|
exp_alfa = 0.1 |
|
|
|
|
chi_alfa = 0.1 |
|
|
|
|
se1 = StructureEstimator(self.s1, exp_alfa, chi_alfa) |
|
|
|
|
self.assertEqual(self.s1, se1._sample_path) |
|
|
|
|
#self.assertEqual(self.s1, se1._sample_path) |
|
|
|
|
self.assertTrue(np.array_equal(se1._nodes, np.array(self.s1.structure.nodes_labels))) |
|
|
|
|
self.assertTrue(np.array_equal(se1._nodes_indxs, self.s1.structure.nodes_indexes)) |
|
|
|
|
self.assertTrue(np.array_equal(se1._nodes_vals, self.s1.structure.nodes_values)) |
|
|
|
|
self.assertEqual(se1._exp_test_sign, exp_alfa) |
|
|
|
|
self.assertEqual(se1._chi_test_alfa, chi_alfa) |
|
|
|
|
self.assertIsInstance(se1._complete_graph, nx.DiGraph) |
|
|
|
|
self.assertIsInstance(se1._cache, Cache) |
|
|
|
|
#self.assertIsInstance(se1._cache, Cache) |
|
|
|
|
|
|
|
|
|
def test_build_complete_graph(self): |
|
|
|
|
exp_alfa = 0.1 |
|
|
|
@ -79,14 +79,10 @@ class TestStructureEstimator(unittest.TestCase): |
|
|
|
|
def test_time(self): |
|
|
|
|
se1 = StructureEstimator(self.s1, 0.1, 0.1) |
|
|
|
|
lp = LineProfiler() |
|
|
|
|
#lp.add_function(se1.complete_test) |
|
|
|
|
#lp.add_function(se1.one_iteration_of_CTPC_algorithm) |
|
|
|
|
#lp.add_function(se1.independence_test) |
|
|
|
|
MULTI_PROCESSING = False ###### MODIFICARE QUI SINGLE/MULTI PROCESS |
|
|
|
|
lp_wrapper = lp(se1.ctpc_algorithm) |
|
|
|
|
lp_wrapper() |
|
|
|
|
lp_wrapper(MULTI_PROCESSING) |
|
|
|
|
lp.print_stats() |
|
|
|
|
#print("Last time", lp.dump_stats()) |
|
|
|
|
#print("Exec Time", timeit.timeit(se1.ctpc_algorithm, number=1)) |
|
|
|
|
print(se1._result_graph.edges) |
|
|
|
|
print(self.s1.structure.edges) |
|
|
|
|
for ed in self.s1.structure.edges: |
|
|
|
@ -100,12 +96,14 @@ class TestStructureEstimator(unittest.TestCase): |
|
|
|
|
print("Adj Matrix:", nx.adj_matrix(se1._result_graph).toarray().astype(bool)) |
|
|
|
|
#se1.save_results() |
|
|
|
|
|
|
|
|
|
""" |
|
|
|
|
def test_memory(self): |
|
|
|
|
se1 = StructureEstimator(self.s1, 0.1, 0.1) |
|
|
|
|
se1.ctpc_algorithm() |
|
|
|
|
current_process = psutil.Process(os.getpid()) |
|
|
|
|
mem = current_process.memory_info().rss |
|
|
|
|
print("Average Memory Usage in MB:", mem / 10**6) |
|
|
|
|
""" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
|
|