From 34d0305374461be92a69f5c6d1cfc666ba370603 Mon Sep 17 00:00:00 2001 From: Luca Moretti Date: Tue, 22 Dec 2020 14:06:48 +0100 Subject: [PATCH] Updated test --- .../test_structure_score_based_estimator.py | 59 ------------------- ..._structure_score_based_estimator_server.py | 2 +- 2 files changed, 1 insertion(+), 60 deletions(-) delete mode 100644 main_package/copia/test_structure_score_based_estimator.py diff --git a/main_package/copia/test_structure_score_based_estimator.py b/main_package/copia/test_structure_score_based_estimator.py deleted file mode 100644 index e0ec2e5..0000000 --- a/main_package/copia/test_structure_score_based_estimator.py +++ /dev/null @@ -1,59 +0,0 @@ -import sys -sys.path.append("../../classes/") -import glob -import math -import os -import unittest - -import networkx as nx -import numpy as np -import psutil -from line_profiler import LineProfiler -import copy - -import utility.cache as ch -import structure_graph.sample_path as sp -import estimators.structure_score_based_estimator as se -import utility.json_importer as ji - -from multiprocessing import set_start_method - - - - -class TestStructureScoreBasedEstimator(unittest.TestCase): - - @classmethod - def setUpClass(cls): - #cls.read_files = glob.glob(os.path.join('../../data', "*.json")) - cls.importer = ji.JsonImporter("/home/alessandro/Documents/ctbn_cba/data/networks_and_trajectories_ternary_data_15.json", 'samples', 'dyn.str', 'variables', 'Time', 'Name') - cls.s1 = sp.SamplePath(cls.importer) - cls.s1.build_trajectories() - cls.s1.build_structure() - - - - def test_structure(self): - true_edges = copy.deepcopy(self.s1.structure.edges) - true_edges = set(map(tuple, true_edges)) - - set_start_method("spawn") - se1 = se.StructureScoreBasedEstimator(self.s1) - edges = se1.estimate_structure( - max_parents = None, - iterations_number = 100, - patience = 35, - tabu_length = 15, - tabu_rules_duration = 15, - optimizer = 'tabu', - disable_multiprocessing=False - ) - - - self.assertEqual(edges, true_edges) - - - -if __name__ == '__main__': - unittest.main() - diff --git a/main_package/tests/estimators/test_structure_score_based_estimator_server.py b/main_package/tests/estimators/test_structure_score_based_estimator_server.py index 34f1eaf..ef3f205 100644 --- a/main_package/tests/estimators/test_structure_score_based_estimator_server.py +++ b/main_package/tests/estimators/test_structure_score_based_estimator_server.py @@ -28,7 +28,7 @@ class TestStructureScoreBasedEstimator(unittest.TestCase): def test_structure(self): #cls.read_files = glob.glob(os.path.join('../../data', "*.json")) - self.importer = ji.JsonImporter("/home/alessandro/Documents/ctbn_cba/data/networks_and_trajectories_ternary_data_6.json", 'samples', 'dyn.str', 'variables', 'Time', 'Name') + self.importer = ji.JsonImporter("/home/alessandro/Documents/ctbn_cba/data/networks_and_trajectories_ternary_data_10.json", 'samples', 'dyn.str', 'variables', 'Time', 'Name') self.s1 = sp.SamplePath(self.importer) self.s1.build_trajectories() self.s1.build_structure()