1
0
Fork 0

updated tests file path location

master
Luca Moretti 4 years ago
parent 8ce2d6ee04
commit 1b11de4503
  1. 23
      main_package/classes/estimators/structure_score_based_estimator.py
  2. 2
      main_package/tests/estimators/test_parameters_estimator.py
  3. 2
      main_package/tests/estimators/test_structure_constraint_based_estimator.py
  4. 6
      main_package/tests/estimators/test_structure_score_based_estimator.py
  5. 2
      main_package/tests/structure_graph/test_networkgraph.py
  6. 2
      main_package/tests/structure_graph/test_sample_path.py

@ -47,7 +47,7 @@ class StructureScoreBasedEstimator(se.StructureEstimator):
super().__init__(sample_path) super().__init__(sample_path)
@timing
def estimate_structure(self, max_parents:int = None, iterations_number:int= 40, patience:int = None ): def estimate_structure(self, max_parents:int = None, iterations_number:int= 40, patience:int = None ):
""" """
Compute the score-based algorithm to find the optimal structure Compute the score-based algorithm to find the optimal structure
@ -86,7 +86,7 @@ class StructureScoreBasedEstimator(se.StructureEstimator):
#list_edges_partial = p.map(estimate_parents, self.nodes) #list_edges_partial = p.map(estimate_parents, self.nodes)
'Concatenate all the edges list' 'Concatenate all the edges list'
list_edges = list(itertools.chain.from_iterable(list_edges_partial)) set_list_edges = set(itertools.chain.from_iterable(list_edges_partial))
print('-------------------------') print('-------------------------')
@ -95,7 +95,6 @@ class StructureScoreBasedEstimator(se.StructureEstimator):
n_missing_edges = 0 n_missing_edges = 0
n_added_fake_edges = 0 n_added_fake_edges = 0
set_list_edges = set(list_edges)
n_added_fake_edges = len(set_list_edges.difference(true_edges)) n_added_fake_edges = len(set_list_edges.difference(true_edges))
@ -121,7 +120,7 @@ class StructureScoreBasedEstimator(se.StructureEstimator):
print(f"n archi reali non trovati: {n_missing_edges}") print(f"n archi reali non trovati: {n_missing_edges}")
print(f"n archi non reali aggiunti: {n_added_fake_edges}") print(f"n archi non reali aggiunti: {n_added_fake_edges}")
print(true_edges) print(true_edges)
print(list_edges) print(set_list_edges)
print(f"precision: {precision} ") print(f"precision: {precision} ")
print(f"recall: {recall} ") print(f"recall: {recall} ")
@ -218,21 +217,5 @@ class StructureScoreBasedEstimator(se.StructureEstimator):
return score return score
def generate_possible_sub_sets_of_size(self, u: typing.List, size: int, parent_label: str):
"""
Creates a list containing all possible subsets of the list u of size size,
that do not contains a the node identified by parent_label.
Parameters:
u: the list of nodes
size: the size of the subsets
parent_label: the nodes to exclude in the subsets generation
Returns:
a Map Object containing a list of lists
"""
list_without_test_parent = u[:]
list_without_test_parent.remove(parent_label)
return map(list, itertools.combinations(list_without_test_parent, size))

@ -17,7 +17,7 @@ class TestParametersEstimatior(unittest.TestCase):
@classmethod @classmethod
def setUpClass(cls) -> None: def setUpClass(cls) -> None:
cls.read_files = glob.glob(os.path.join('../../data', "*.json")) cls.read_files = glob.glob(os.path.join('../../data', "*.json"))
cls.importer = ji.JsonImporter(cls.read_files[0], 'samples', 'dyn.str', 'variables', 'Time', 'Name') cls.importer = ji.JsonImporter("../../data/networks_and_trajectories_binary_data_01_3.json", 'samples', 'dyn.str', 'variables', 'Time', 'Name')
cls.s1 = sp.SamplePath(cls.importer) cls.s1 = sp.SamplePath(cls.importer)
cls.s1.build_trajectories() cls.s1.build_trajectories()
cls.s1.build_structure() cls.s1.build_structure()

@ -21,7 +21,7 @@ class TestStructureConstraintBasedEstimator(unittest.TestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
cls.read_files = glob.glob(os.path.join('../../data', "*.json")) cls.read_files = glob.glob(os.path.join('../../data', "*.json"))
cls.importer = ji.JsonImporter(cls.read_files[0], 'samples', 'dyn.str', 'variables', 'Time', 'Name') cls.importer = ji.JsonImporter("../../data/networks_and_trajectories_binary_data_01_3.json", 'samples', 'dyn.str', 'variables', 'Time', 'Name')
cls.s1 = sp.SamplePath(cls.importer) cls.s1 = sp.SamplePath(cls.importer)
cls.s1.build_trajectories() cls.s1.build_trajectories()
cls.s1.build_structure() cls.s1.build_structure()

@ -21,8 +21,8 @@ class TestStructureScoreBasedEstimator(unittest.TestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
cls.read_files = glob.glob(os.path.join('../../data', "*.json")) #cls.read_files = glob.glob(os.path.join('../../data', "*.json"))
cls.importer = ji.JsonImporter(cls.read_files[0], 'samples', 'dyn.str', 'variables', 'Time', 'Name') cls.importer = ji.JsonImporter("../../data/networks_and_trajectories_binary_data_01_3.json", 'samples', 'dyn.str', 'variables', 'Time', 'Name')
cls.s1 = sp.SamplePath(cls.importer) cls.s1 = sp.SamplePath(cls.importer)
cls.s1.build_trajectories() cls.s1.build_trajectories()
cls.s1.build_structure() cls.s1.build_structure()
@ -32,7 +32,7 @@ class TestStructureScoreBasedEstimator(unittest.TestCase):
def test_esecuzione(self): def test_esecuzione(self):
se1 = se.StructureScoreBasedEstimator(self.s1) se1 = se.StructureScoreBasedEstimator(self.s1)
se1.estimate_structure( se1.estimate_structure(
max_parents = 3, max_parents = 6,
iterations_number = 80, iterations_number = 80,
patience = None patience = None
) )

@ -17,7 +17,7 @@ class TestNetworkGraph(unittest.TestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
cls.read_files = glob.glob(os.path.join('../../data', "*.json")) cls.read_files = glob.glob(os.path.join('../../data', "*.json"))
cls.importer = ji.JsonImporter(cls.read_files[0], 'samples', 'dyn.str', 'variables', 'Time', 'Name') cls.importer = ji.JsonImporter("../../data/networks_and_trajectories_binary_data_01_3.json", 'samples', 'dyn.str', 'variables', 'Time', 'Name')
cls.s1 = sp.SamplePath(cls.importer) cls.s1 = sp.SamplePath(cls.importer)
cls.s1.build_trajectories() cls.s1.build_trajectories()
cls.s1.build_structure() cls.s1.build_structure()

@ -14,7 +14,7 @@ class TestSamplePath(unittest.TestCase):
@classmethod @classmethod
def setUpClass(cls) -> None: def setUpClass(cls) -> None:
cls.read_files = glob.glob(os.path.join('../../data', "*.json")) cls.read_files = glob.glob(os.path.join('../../data', "*.json"))
cls.importer = ji.JsonImporter(cls.read_files[0], 'samples', 'dyn.str', 'variables', 'Time', 'Name') cls.importer = ji.JsonImporter("../../data/networks_and_trajectories_binary_data_01_3.json", 'samples', 'dyn.str', 'variables', 'Time', 'Name')
def test_init(self): def test_init(self):
s1 = sp.SamplePath(self.importer) s1 = sp.SamplePath(self.importer)