1
0
Fork 0

Fix tests dataset problem; modify workflow

master
Filippo Martini 4 years ago
parent 762d169b9e
commit df9a7d8ccc
  1. 2
      .github/workflows/python-PyCTBN-package.yml
  2. 3
      .idea/.gitignore
  3. 8
      .idea/PyCTBN.iml
  4. 6
      .idea/inspectionProfiles/profiles_settings.xml
  5. 4
      .idea/misc.xml
  6. 8
      .idea/modules.xml
  7. 6
      .idea/vcs.xml
  8. 2
      PyCTBN/tests/structure_graph/test_networkgraph.py
  9. 18
      PyCTBN/tests/structure_graph/test_sample_path.py
  10. 2
      PyCTBN/tests/structure_graph/test_trajectory.py

@ -36,4 +36,4 @@ jobs:
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
python -m unittest -v PyCTBN/tests/structure_graph/test_sample_path.py
pytest PyCTBN/tests/

3
.idea/.gitignore vendored

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Python 3.8" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8" project-jdk-type="Python SDK" />
</project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/PyCTBN.iml" filepath="$PROJECT_DIR$/.idea/PyCTBN.iml" />
</modules>
</component>
</project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

@ -15,7 +15,7 @@ class TestNetworkGraph(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.read_files = glob.glob(os.path.join('./PyCTBN/test_data', "*.json"))
cls.importer = JsonImporter(cls.read_files[0], 'samples', 'dyn.str', 'variables', 'Time', 'Name')
cls.importer = JsonImporter(cls.read_files[2], 'samples', 'dyn.str', 'variables', 'Time', 'Name')
cls.importer.import_data(0)
cls.s1 = SamplePath(cls.importer)
cls.s1.build_trajectories()

@ -17,17 +17,17 @@ class TestSamplePath(unittest.TestCase):
cls.read_files = glob.glob(os.path.join('./PyCTBN/test_data', "*.json"))
def test_init_not_initialized_importer(self):
importer = JsonImporter(self.read_files[0], 'samples', 'dyn.str', 'variables', 'Time', 'Name')
importer = JsonImporter(self.read_files[2], 'samples', 'dyn.str', 'variables', 'Time', 'Name')
self.assertRaises(RuntimeError, SamplePath, importer)
def test_init_not_filled_dataframse(self):
importer = JsonImporter(self.read_files[0], 'samples', 'dyn.str', 'variables', 'Time', 'Name')
importer = JsonImporter(self.read_files[2], 'samples', 'dyn.str', 'variables', 'Time', 'Name')
importer.import_data(0)
importer.clear_concatenated_frame()
self.assertRaises(RuntimeError, SamplePath, importer)
def test_init(self):
importer = JsonImporter(self.read_files[0], 'samples', 'dyn.str', 'variables', 'Time', 'Name')
importer = JsonImporter(self.read_files[2], 'samples', 'dyn.str', 'variables', 'Time', 'Name')
importer.import_data(0)
s1 = SamplePath(importer)
self.assertIsNone(s1.trajectories)
@ -36,14 +36,14 @@ class TestSamplePath(unittest.TestCase):
self.assertIsNone(s1._total_variables_count)
def test_build_trajectories(self):
importer = JsonImporter(self.read_files[0], 'samples', 'dyn.str', 'variables', 'Time', 'Name')
importer = JsonImporter(self.read_files[2], 'samples', 'dyn.str', 'variables', 'Time', 'Name')
importer.import_data(0)
s1 = SamplePath(importer)
s1.build_trajectories()
self.assertIsInstance(s1.trajectories, Trajectory)
def test_build_structure(self):
importer = JsonImporter(self.read_files[0], 'samples', 'dyn.str', 'variables', 'Time', 'Name')
importer = JsonImporter(self.read_files[2], 'samples', 'dyn.str', 'variables', 'Time', 'Name')
importer.import_data(0)
s1 = SamplePath(importer)
s1.build_structure()
@ -51,7 +51,7 @@ class TestSamplePath(unittest.TestCase):
self.assertEqual(s1._total_variables_count, len(s1._importer.sorter))
def test_build_structure_bad_sorter(self):
importer = JsonImporter(self.read_files[0], 'samples', 'dyn.str', 'variables', 'Time', 'Name')
importer = JsonImporter(self.read_files[2], 'samples', 'dyn.str', 'variables', 'Time', 'Name')
importer.import_data(0)
s1 = SamplePath(importer)
importer._sorter[0],importer._sorter[1]= importer._sorter[1],importer._sorter[0]
@ -59,7 +59,7 @@ class TestSamplePath(unittest.TestCase):
self.assertRaises(RuntimeError, s1.build_structure)
def test_build_saplepath_no_prior_net_structure(self):
importer = JsonImporter(self.read_files[0], 'samples', 'dyn.str', 'variables', 'Time', 'Name')
importer = JsonImporter(self.read_files[2], 'samples', 'dyn.str', 'variables', 'Time', 'Name')
importer.import_data(0)
importer._df_structure = None
s1 = SamplePath(importer)
@ -68,13 +68,13 @@ class TestSamplePath(unittest.TestCase):
self.assertFalse(s1.structure.edges)
def test_buid_samplepath_no_variables(self):
importer = JsonImporter(self.read_files[0], 'samples', 'dyn.str', 'variables', 'Time', 'Name')
importer = JsonImporter(self.read_files[2], 'samples', 'dyn.str', 'variables', 'Time', 'Name')
importer.import_data(0)
importer._df_variables = None
self.assertRaises(RuntimeError, SamplePath, importer)
def test_buid_samplepath_no_concatenated_samples(self):
importer = JsonImporter(self.read_files[0], 'samples', 'dyn.str', 'variables', 'Time', 'Name')
importer = JsonImporter(self.read_files[2], 'samples', 'dyn.str', 'variables', 'Time', 'Name')
importer.import_data(0)
importer._concatenated_samples = None
self.assertRaises(RuntimeError, SamplePath, importer)

@ -12,7 +12,7 @@ class TestTrajectory(unittest.TestCase):
@classmethod
def setUpClass(cls) -> None:
cls.read_files = glob.glob(os.path.join('./PyCTBN/test_data', "*.json"))
cls.importer = JsonImporter(cls.read_files[0], 'samples', 'dyn.str', 'variables', 'Time', 'Name')
cls.importer = JsonImporter(cls.read_files[2], 'samples', 'dyn.str', 'variables', 'Time', 'Name')
cls.importer.import_data(0)
def test_init(self):