Coverage for biobb_pytorch / test / unitests / test_mdae / test_encode_model.py: 82%

17 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.encode_model import evaluateEncoder 

4import numpy as np 

5 

6 

7class TestEncodeModel: 

8 def setup_class(self): 

9 fx.test_setup(self, 'evaluateEncoder') 

10 

11 def teardown_class(self): 

12 fx.test_teardown(self) 

13 

14 def test_encode_model(self): 

15 evaluateEncoder(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 'latent' in results or 'encoded' in results or 'z' in results, "Results should contain encoded/latent data" 

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 latent space dimensions 

24 if 'latent' in results and 'latent' in ref_results: 

25 assert results['latent'].shape[0] == ref_results['latent'].shape[0], "Number of samples should match"