Coverage for biobb_pytorch / test / unitests / test_mdae / test_evaluate_model.py: 78%

18 statements  

« prev     ^ index     » next       coverage.py v7.13.2, created at 2026-02-02 16:33 +0000

1# type: ignore 

2from biobb_common.tools import test_fixtures as fx 

3from biobb_pytorch.mdae.evaluate_model import evaluateModel 

4import numpy as np 

5 

6 

7class TestEvaluateModel: 

8 def setup_class(self): 

9 fx.test_setup(self, 'evaluateModel') 

10 

11 def teardown_class(self): 

12 fx.test_teardown(self) 

13 

14 def test_evaluate_model(self): 

15 evaluateModel(properties=self.properties, **self.paths) 

16 assert fx.not_empty(self.paths['output_results_npz_path']) 

17 

18 results = np.load(self.paths['output_results_npz_path'], allow_pickle=True) 

19 assert 'xhat' in results or 'z' in results or 'eval_loss' in results, "Results should contain evaluation data (xhat, z, or eval_loss)" 

20 

21 if 'ref_output_results_npz_path' in self.paths: 

22 ref_results = np.load(self.paths['ref_output_results_npz_path'], allow_pickle=True) 

23 # Compare key metrics 

24 for key in ['loss', 'mse', 'reconstruction_error']: 

25 if key in results and key in ref_results: 

26 assert isinstance(results[key], (np.ndarray, float)), f"{key} should be numeric"