Coverage for tests/test_properties.py: 88%

29 statements  

« prev     ^ index     » next       coverage.py v7.9.1, created at 2025-07-11 14:46 +0200

1import unittest 

2 

3import yaml 

4import numpy as np 

5import MPP.run as run_module 

6 

7 

8config_dir = "/data/evaluation/MPP/stochastic_MPP_Felix/data_production/sm/config/" 

9root = "/data/evaluation/MPP/stochastic_MPP_Felix/data_production/sm/results/" 

10 

11SYSTEMS = [ 

12 "HP35", 

13 "PDZ3_7", 

14 "aSyn_rdc_200ns", 

15 "HP35_stoch", 

16] 

17SETUPS = [ 

18 "t", 

19 "kl", 

20 "t_js", 

21 "kl_js", 

22 "gpcca", 

23] 

24 

25with open(f"{config_dir}lumpings.yaml") as f: 

26 lumpings = yaml.safe_load(f) 

27 

28 

29def get_d(system, setup, rmsd=False): 

30 d = run_module.Data( 

31 f"/data/evaluation/MPP/stochastic_MPP_Felix/data_production/sm/config/{system}.yaml" 

32 ) 

33 d.setup_mpp( 

34 lumpings[setup]["kernel similarity"], 

35 lumpings[setup]["feature kernel"], 

36 ) 

37 if setup == "gpcca": 37 ↛ 38line 37 didn't jump to line 38 because the condition on line 37 was never true

38 d.perform_gpcca("ref", f"{root}{system}/{setup}/Z.npy") 

39 else: 

40 d.perform_mpp(f"{root}{system}/{setup}/Z.npy") 

41 if rmsd: 41 ↛ 42line 41 didn't jump to line 42 because the condition on line 41 was never true

42 d.mpp.load_rmsd(f"{root}{system}/{setup}/rmsd.npy") 

43 return d 

44 

45 

46class TestProperties(unittest.TestCase): 

47 def setUp(self): 

48 self.d = get_d("HP35", "t") 

49 self.mpp = self.d.mpp 

50 

51 def test_shannon_entropy(self): 

52 np.testing.assert_allclose(self.mpp.shannon_entropy[0], 0.73862646) 

53 

54 def test_gmrq(self): 

55 np.testing.assert_allclose(self.mpp.gmrq[0], 2.5071318) 

56 

57 def test_davies_bouldin_index(self): 

58 np.testing.assert_allclose(self.mpp.davies_bouldin_index[0], 2.20325216)