Old engine for Continuous Time Bayesian Networks. Superseded by reCTBN. 🐍
https://github.com/madlabunimib/PyCTBN
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.3 KiB
34 lines
1.3 KiB
4 years ago
|
|
||
4 years ago
|
# License: MIT License
|
||
|
|
||
|
|
||
4 years ago
|
import unittest
|
||
|
import numpy as np
|
||
4 years ago
|
import glob
|
||
4 years ago
|
import os
|
||
4 years ago
|
|
||
3 years ago
|
from pyctbn.legacy.structure_graph.trajectory import Trajectory
|
||
|
from pyctbn.legacy.utility.json_importer import JsonImporter
|
||
4 years ago
|
|
||
4 years ago
|
class TestTrajectory(unittest.TestCase):
|
||
4 years ago
|
|
||
4 years ago
|
@classmethod
|
||
4 years ago
|
def setUpClass(cls) -> None:
|
||
3 years ago
|
cls.read_files = glob.glob(os.path.join('./tests/data', "*.json"))
|
||
4 years ago
|
cls.importer = JsonImporter(cls.read_files[2], 'samples', 'dyn.str', 'variables', 'Time', 'Name')
|
||
4 years ago
|
cls.importer.import_data(0)
|
||
|
|
||
4 years ago
|
def test_init(self):
|
||
4 years ago
|
t1 = Trajectory(self.importer.build_list_of_samples_array(self.importer.concatenated_samples),
|
||
|
len(self.importer.sorter) + 1)
|
||
|
self.assertTrue(np.array_equal(self.importer.concatenated_samples.iloc[:, 0].to_numpy(), t1.times))
|
||
|
self.assertTrue(np.array_equal(self.importer.concatenated_samples.iloc[:,1:].to_numpy(), t1.complete_trajectory))
|
||
|
self.assertTrue(np.array_equal(self.importer.concatenated_samples.iloc[:, 1: len(self.importer.sorter) + 1], t1.trajectory))
|
||
|
self.assertEqual(len(self.importer.sorter) + 1, t1._original_cols_number)
|
||
4 years ago
|
|
||
4 years ago
|
self.assertEqual(self.importer.concatenated_samples.iloc[:,1:].to_numpy().shape[0], t1.size())
|
||
|
print(t1)
|
||
4 years ago
|
|
||
|
if __name__ == '__main__':
|
||
|
unittest.main()
|