diff --git a/main_package/.scannerwork/.sonar_lock b/main_package/.scannerwork/.sonar_lock new file mode 100644 index 0000000..e69de29 diff --git a/main_package/.scannerwork/report-task.txt b/main_package/.scannerwork/report-task.txt new file mode 100644 index 0000000..5394593 --- /dev/null +++ b/main_package/.scannerwork/report-task.txt @@ -0,0 +1,6 @@ +projectKey=Ctbn_Project +serverUrl=http://localhost:9000 +serverVersion=8.4.1.35646 +dashboardUrl=http://localhost:9000/dashboard?id=Ctbn_Project +ceTaskId=AXPs4gCNB9mzoAo2hiLI +ceTaskUrl=http://localhost:9000/api/ce/task?id=AXPs4gCNB9mzoAo2hiLI diff --git a/main_package/basic_main.py b/main_package/basic_main.py new file mode 100644 index 0000000..b46eb9a --- /dev/null +++ b/main_package/basic_main.py @@ -0,0 +1,39 @@ +import glob +import os + +import sys +sys.path.append("./classes/") + +import network_graph as ng +import sample_path as sp +import set_of_cims as sofc +import parameters_estimator as pe +import json_importer as ji + + +def main(): + read_files = glob.glob(os.path.join('./data', "*.json")) #Take all json files in this dir + #import data + importer = ji.JsonImporter(read_files[0], 'samples', 'dyn.str', 'variables', 'Time', 'Name') + #Create a SamplePath Obj + s1 = sp.SamplePath(importer) + #Build The trajectries and the structural infos + s1.build_trajectories() + s1.build_structure() + #From The Structure Object build the Graph + g = ng.NetworkGraph(s1.structure) + #Select a node you want to estimate the parameters + node = g.nodes[1] + #Init the graph specifically for THIS node + g.fast_init(node) + #Use SamplePath and Grpah to create a ParametersEstimator Object + p1 = pe.ParametersEstimator(s1, g) + #Init the peEst specifically for THIS node + p1.fast_init(node) + #Compute the parameters + sofc1 = p1.compute_parameters_for_node(node) + #The est CIMS are inside the resultant SetOfCIms Obj + print(sofc1.actual_cims) + +if __name__ == "__main__": + main() diff --git a/main_package/classes/abstract_sample_path.py b/main_package/classes/abstract_sample_path.py index 3d71ca1..f2f058f 100644 --- a/main_package/classes/abstract_sample_path.py +++ b/main_package/classes/abstract_sample_path.py @@ -1,4 +1,5 @@ from abc import ABC, abstractmethod + import abstract_importer as ai diff --git a/main_package/classes/cache.py b/main_package/classes/cache.py index f9a1f7a..31c5466 100644 --- a/main_package/classes/cache.py +++ b/main_package/classes/cache.py @@ -1,4 +1,5 @@ import typing + import set_of_cims as sofc diff --git a/main_package/classes/json_importer.py b/main_package/classes/json_importer.py index bde6212..708c6ad 100644 --- a/main_package/classes/json_importer.py +++ b/main_package/classes/json_importer.py @@ -1,11 +1,13 @@ -import pandas as pd import json import typing -from abstract_importer import AbstractImporter + +import pandas as pd + +import abstract_importer as ai -class JsonImporter(AbstractImporter): +class JsonImporter(ai.AbstractImporter): """ Implements the Interface AbstractImporter and adds all the necessary methods to process and prepare the data in json ext. with the following structure: diff --git a/main_package/classes/network_graph.py b/main_package/classes/network_graph.py index f01c270..7f7b99c 100644 --- a/main_package/classes/network_graph.py +++ b/main_package/classes/network_graph.py @@ -1,7 +1,8 @@ +import typing + import networkx as nx import numpy as np -import typing class NetworkGraph: @@ -21,7 +22,7 @@ class NetworkGraph: :_transition_scalar_indexing_structure: the indexing structure for transition computation :_time_filtering: the columns filtering structure used in the computation of the state res times :_transition_filtering: the columns filtering structure used in the computation of the transition from one state to another - :self._p_combs_structure: all the possibile parents states combination for every node in the net + :self._p_combs_structure: all the possible parents states combination for every node in the net """ def __init__(self, graph_struct): diff --git a/main_package/classes/parameters_estimator.py b/main_package/classes/parameters_estimator.py index 566e37c..a2829da 100644 --- a/main_package/classes/parameters_estimator.py +++ b/main_package/classes/parameters_estimator.py @@ -1,9 +1,10 @@ import numpy as np -import sets_of_cims_container as acims -import set_of_cims as sofc -import sample_path as sp + import network_graph as ng +import sample_path as sp +import set_of_cims as sofc +import sets_of_cims_container as acims class ParametersEstimator: diff --git a/main_package/classes/sample_path.py b/main_package/classes/sample_path.py index 49faefe..e365e85 100644 --- a/main_package/classes/sample_path.py +++ b/main_package/classes/sample_path.py @@ -1,7 +1,7 @@ import abstract_sample_path as asam import json_importer as imp -import trajectory as tr import structure as st +import trajectory as tr class SamplePath(asam.AbstractSamplePath): diff --git a/main_package/classes/set_of_cims.py b/main_package/classes/set_of_cims.py index 066dfcd..d45b1f5 100644 --- a/main_package/classes/set_of_cims.py +++ b/main_package/classes/set_of_cims.py @@ -1,5 +1,7 @@ -import numpy as np import typing + +import numpy as np + import conditional_intensity_matrix as cim diff --git a/main_package/classes/structure.py b/main_package/classes/structure.py index a462e11..3dee1c9 100644 --- a/main_package/classes/structure.py +++ b/main_package/classes/structure.py @@ -1,4 +1,5 @@ import typing as ty + import numpy as np diff --git a/main_package/classes/structure_estimator.py b/main_package/classes/structure_estimator.py index c352608..6f36790 100644 --- a/main_package/classes/structure_estimator.py +++ b/main_package/classes/structure_estimator.py @@ -1,20 +1,20 @@ -import numpy as np import itertools -import networkx as nx -from networkx.readwrite import json_graph import json import typing -from scipy.stats import f as f_dist -from scipy.stats import chi2 as chi2_dist +import networkx as nx +import numpy as np +from networkx.readwrite import json_graph +from scipy.stats import chi2 as chi2_dist +from scipy.stats import f as f_dist -import sample_path as sp -import structure as st -import network_graph as ng +import cache as ch import conditional_intensity_matrix as condim +import network_graph as ng import parameters_estimator as pe -import cache as ch +import sample_path as sp +import structure as st class StructureEstimator: diff --git a/main_package/tests/coverage.xml b/main_package/tests/coverage.xml new file mode 100644 index 0000000..cef006f --- /dev/null +++ b/main_package/tests/coverage.xml @@ -0,0 +1,963 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/main_package/tests/test_cache.py b/main_package/tests/test_cache.py index 8dd752a..bbb89e9 100644 --- a/main_package/tests/test_cache.py +++ b/main_package/tests/test_cache.py @@ -1,5 +1,5 @@ import sys -sys.path.append("/Users/Zalum/Desktop/Tesi/CTBN_Project/main_package/classes/") +sys.path.append("../classes/") import unittest import numpy as np diff --git a/main_package/tests/test_cim.py b/main_package/tests/test_cim.py index 0a6784e..13f41a6 100644 --- a/main_package/tests/test_cim.py +++ b/main_package/tests/test_cim.py @@ -1,5 +1,5 @@ import sys -sys.path.append("/Users/Zalum/Desktop/Tesi/CTBN_Project/main_package/classes/") +sys.path.append("../classes/") import unittest import numpy as np diff --git a/main_package/tests/test_json_importer.py b/main_package/tests/test_json_importer.py index 44214f0..f940ae6 100644 --- a/main_package/tests/test_json_importer.py +++ b/main_package/tests/test_json_importer.py @@ -1,5 +1,5 @@ import sys -sys.path.append("/Users/Zalum/Desktop/Tesi/CTBN_Project/main_package/classes/") +sys.path.append("../classes/") import unittest import os import glob @@ -7,8 +7,6 @@ import numpy as np import pandas as pd import json_importer as ji -from line_profiler import LineProfiler - import json diff --git a/main_package/tests/test_networkgraph.py b/main_package/tests/test_networkgraph.py index ad58636..c03b4cb 100644 --- a/main_package/tests/test_networkgraph.py +++ b/main_package/tests/test_networkgraph.py @@ -1,12 +1,11 @@ import sys -sys.path.append("/Users/Zalum/Desktop/Tesi/CTBN_Project/main_package/classes/") +sys.path.append("../classes/") import unittest import glob import os import networkx as nx import numpy as np import itertools -from line_profiler import LineProfiler import sample_path as sp import network_graph as ng diff --git a/main_package/tests/test_parameters_estimator.py b/main_package/tests/test_parameters_estimator.py index 552277e..be75668 100644 --- a/main_package/tests/test_parameters_estimator.py +++ b/main_package/tests/test_parameters_estimator.py @@ -1,10 +1,9 @@ import sys -sys.path.append("/Users/Zalum/Desktop/Tesi/CTBN_Project/main_package/classes/") +sys.path.append("../classes/") import unittest import numpy as np import glob import os -from line_profiler import LineProfiler import network_graph as ng import sample_path as sp diff --git a/main_package/tests/test_sample_path.py b/main_package/tests/test_sample_path.py index a3c4713..49e3641 100644 --- a/main_package/tests/test_sample_path.py +++ b/main_package/tests/test_sample_path.py @@ -1,5 +1,5 @@ import sys -sys.path.append("/Users/Zalum/Desktop/Tesi/CTBN_Project/main_package/classes/") +sys.path.append("../classes/") import unittest import glob import os diff --git a/main_package/tests/test_setofcims.py b/main_package/tests/test_setofcims.py index 7d30095..f158472 100644 --- a/main_package/tests/test_setofcims.py +++ b/main_package/tests/test_setofcims.py @@ -1,5 +1,5 @@ import sys -sys.path.append("/Users/Zalum/Desktop/Tesi/CTBN_Project/main_package/classes/") +sys.path.append("../classes/") import unittest import numpy as np import itertools diff --git a/main_package/tests/test_sets_of_cims_container.py b/main_package/tests/test_sets_of_cims_container.py index ad38d4f..e2b05b8 100644 --- a/main_package/tests/test_sets_of_cims_container.py +++ b/main_package/tests/test_sets_of_cims_container.py @@ -1,7 +1,8 @@ +import sys +sys.path.append("../classes/") import unittest - -import sets_of_cims_container as scc import set_of_cims as sc +import sets_of_cims_container as scc class TestSetsOfCimsContainer(unittest.TestCase): diff --git a/main_package/tests/test_structure.py b/main_package/tests/test_structure.py index cb35072..ee67643 100644 --- a/main_package/tests/test_structure.py +++ b/main_package/tests/test_structure.py @@ -1,5 +1,5 @@ import sys -sys.path.append("/Users/Zalum/Desktop/Tesi/CTBN_Project/main_package/classes/") +sys.path.append("../classes/") import unittest import numpy as np import structure as st diff --git a/main_package/tests/test_structure_estimator.py b/main_package/tests/test_structure_estimator.py index e0001db..9c3aae1 100644 --- a/main_package/tests/test_structure_estimator.py +++ b/main_package/tests/test_structure_estimator.py @@ -1,24 +1,25 @@ import sys -sys.path.append("/Users/Zalum/Desktop/Tesi/CTBN_Project/main_package/classes/") -import unittest -import numpy as np -import networkx as nx +sys.path.append("../classes/") import glob -import os import math -from line_profiler import LineProfiler +import os +import unittest + +import networkx as nx +import numpy as np import psutil +from line_profiler import LineProfiler -import json_importer as ji +import cache as ch import sample_path as sp import structure_estimator as se -import cache as ch +import json_importer as ji class TestStructureEstimator(unittest.TestCase): @classmethod - def setUpClass(cls) -> None: + def setUpClass(cls): 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.s1 = sp.SamplePath(cls.importer) diff --git a/main_package/tests/test_trajectory.py b/main_package/tests/test_trajectory.py index 3352008..62d3da8 100644 --- a/main_package/tests/test_trajectory.py +++ b/main_package/tests/test_trajectory.py @@ -1,5 +1,5 @@ import sys -sys.path.append("/Users/Zalum/Desktop/Tesi/CTBN_Project/main_package/classes/") +sys.path.append("../classes/") import unittest import numpy as np