From 3ee5785c590ba6988b632a2a20fd7ec7e85a0ddc Mon Sep 17 00:00:00 2001 From: Dani Bodor Date: Tue, 16 Jan 2024 08:11:58 +0100 Subject: [PATCH] test: suppress some warnings --- deeprank2/dataset.py | 8 +++-- tests/features/test_secondary_structure.py | 6 +++- tests/tools/test_target.py | 39 ++++++++++++---------- 3 files changed, 31 insertions(+), 22 deletions(-) diff --git a/deeprank2/dataset.py b/deeprank2/dataset.py index 0aace279f..02a6ba4a0 100644 --- a/deeprank2/dataset.py +++ b/deeprank2/dataset.py @@ -430,9 +430,11 @@ def save_hist( else: raise ValueError("Please provide valid features names. They must be present in the current :class:`DeeprankDataset` children instance.") - fig.tight_layout() - fig.savefig(fname) - plt.close(fig) + with warnings.catch_warnings(): + warnings.simplefilter("ignore") + fig.tight_layout() + fig.savefig(fname) + plt.close(fig) def _compute_mean_std(self): means = { diff --git a/tests/features/test_secondary_structure.py b/tests/features/test_secondary_structure.py index 5c347b597..7d2ff1ff0 100644 --- a/tests/features/test_secondary_structure.py +++ b/tests/features/test_secondary_structure.py @@ -1,3 +1,5 @@ +import warnings + import numpy as np from deeprank2.domain import nodestorage as Nfeat @@ -19,7 +21,9 @@ def test_secondary_structure_residue(): influence_radius=10, max_edge_length=10, ) - add_features(pdb_path, graph) + with warnings.catch_warnings(): + warnings.simplefilter("ignore") + add_features(pdb_path, graph) # Create a list of node information (residue number, chain ID, and secondary structure features) node_info_list = [[node.id.number, node.id.chain.id, node.features[Nfeat.SECSTRUCT]] for node in graph.nodes] diff --git a/tests/tools/test_target.py b/tests/tools/test_target.py index 32dac919a..577b3aad7 100644 --- a/tests/tools/test_target.py +++ b/tests/tools/test_target.py @@ -2,6 +2,7 @@ import shutil import tempfile import unittest +import warnings from pdb2sql import StructureSimilarity @@ -34,25 +35,27 @@ def test_add_target(self): os.remove(graph_path) def test_compute_ppi_scores(self): - scores = compute_ppi_scores( - os.path.join(self.pdb_path, "1ATN_1w.pdb"), - os.path.join(self.ref, "1ATN.pdb"), - ) + with warnings.catch_warnings(): + warnings.simplefilter("ignore") - sim = StructureSimilarity( - os.path.join(self.pdb_path, "1ATN_1w.pdb"), - os.path.join(self.ref, "1ATN.pdb"), - enforce_residue_matching=False, - ) - lrmsd = sim.compute_lrmsd_fast(method="svd") - irmsd = sim.compute_irmsd_fast(method="svd") - fnat = sim.compute_fnat_fast() - dockq = sim.compute_DockQScore(fnat, lrmsd, irmsd) - binary = irmsd < 4.0 - capri = 4 - for thr, val in zip([6.0, 4.0, 2.0, 1.0], [4, 3, 2, 1], strict=True): - if irmsd < thr: - capri = val + scores = compute_ppi_scores( + os.path.join(self.pdb_path, "1ATN_1w.pdb"), + os.path.join(self.ref, "1ATN.pdb"), + ) + sim = StructureSimilarity( + os.path.join(self.pdb_path, "1ATN_1w.pdb"), + os.path.join(self.ref, "1ATN.pdb"), + enforce_residue_matching=False, + ) + lrmsd = sim.compute_lrmsd_fast(method="svd") + irmsd = sim.compute_irmsd_fast(method="svd") + fnat = sim.compute_fnat_fast() + dockq = sim.compute_DockQScore(fnat, lrmsd, irmsd) + binary = irmsd < 4.0 + capri = 4 + for thr, val in zip([6.0, 4.0, 2.0, 1.0], [4, 3, 2, 1], strict=True): + if irmsd < thr: + capri = val assert scores["irmsd"] == irmsd assert scores["lrmsd"] == lrmsd