Coverage for biobb_pytorch / test / unitests / test_mdae / test_lrp.py: 83%
18 statements
« prev ^ index » next coverage.py v7.13.2, created at 2026-02-02 16:33 +0000
« 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.explainability.LRP import relevance_propagation
4import numpy as np
7class TestLRP:
8 def setup_class(self):
9 fx.test_setup(self, 'lrp')
11 def teardown_class(self):
12 fx.test_teardown(self)
14 def test_lrp(self):
15 relevance_propagation(properties=self.properties, **self.paths)
17 if 'output_results_npz_path' in self.paths and self.paths['output_results_npz_path']:
18 assert fx.not_empty(self.paths['output_results_npz_path'])
20 results = np.load(self.paths['output_results_npz_path'], allow_pickle=True)
21 assert 'global_importance' in results, "Results should contain global_importance scores"
23 if 'ref_output_results_npz_path' in self.paths:
24 ref_results = np.load(self.paths['ref_output_results_npz_path'], allow_pickle=True)
25 # Compare relevance scores structure
26 if 'global_importance' in results and 'global_importance' in ref_results:
27 assert results['global_importance'].shape == ref_results['global_importance'].shape, "Global importance scores should have matching shapes"