diff --git a/tests/domain/test_aminoacidlist.py b/tests/domain/test_aminoacidlist.py index c65700495..98cbb1643 100644 --- a/tests/domain/test_aminoacidlist.py +++ b/tests/domain/test_aminoacidlist.py @@ -1,4 +1,5 @@ import numpy as np + from deeprank2.domain.aminoacidlist import (amino_acids, cysteine, lysine, pyrrolysine, selenocysteine) @@ -16,10 +17,10 @@ def test_all_different_onehot(): if other != amino_acid: try: assert not np.all(amino_acid.onehot == other.onehot) - except AssertionError: + except AssertionError as exc: if other in EXCEPTIONS[0] and amino_acid in EXCEPTIONS[0]: assert np.all(amino_acid.onehot == other.onehot) elif other in EXCEPTIONS[1] and amino_acid in EXCEPTIONS[1]: assert np.all(amino_acid.onehot == other.onehot) else: - raise AssertionError(f"one-hot index {amino_acid.index} is occupied by both {amino_acid} and {other}") \ No newline at end of file + raise AssertionError(f"one-hot index {amino_acid.index} is occupied by both {amino_acid} and {other}") from exc \ No newline at end of file diff --git a/tests/molstruct/test_structure.py b/tests/molstruct/test_structure.py index 55633b18c..b6137ea0d 100644 --- a/tests/molstruct/test_structure.py +++ b/tests/molstruct/test_structure.py @@ -2,9 +2,10 @@ import pickle from multiprocessing.connection import _ForkingPickler +from pdb2sql import pdb2sql + from deeprank2.molstruct.structure import PDBStructure from deeprank2.utils.buildgraph import get_structure -from pdb2sql import pdb2sql def _get_structure(path) -> PDBStructure: @@ -12,7 +13,7 @@ def _get_structure(path) -> PDBStructure: try: structure = get_structure(pdb, "101M") finally: - pdb._close() + pdb._close() # pylint: disable=protected-access assert structure is not None @@ -45,3 +46,4 @@ def test_serialization_fork(): assert loaded_structure.get_chain("A").get_residue(0) == structure.get_chain("A").get_residue(0) assert loaded_structure.get_chain("A").get_residue(0).amino_acid == structure.get_chain("A").get_residue(0).amino_acid assert loaded_structure.get_chain("A").get_residue(0).atoms[0] == structure.get_chain("A").get_residue(0).atoms[0] + assert loaded_structure.get_chain("A").get_residue(0).atoms[0] == structure.get_chain("A").get_residue(0).atoms[0] diff --git a/tests/utils/test_exporters.py b/tests/utils/test_exporters.py index 90da005e4..fc6cb321c 100644 --- a/tests/utils/test_exporters.py +++ b/tests/utils/test_exporters.py @@ -7,6 +7,7 @@ import h5py import pandas as pd + from deeprank2.utils.exporters import (HDF5OutputExporter, OutputExporterCollection, ScatterPlotExporter, @@ -95,7 +96,7 @@ def test_scatter_plot(self): assert os.path.isfile(scatterplot_exporter.get_filename(epoch_number)) - def test_hdf5_output(self): + def test_hdf5_output(self): # pylint: disable=too-many-locals output_exporter = HDF5OutputExporter(self._work_dir) path_output_exporter = os.path.join(self._work_dir, 'output_exporter.hdf5') entry_names = ["entry1", "entry2", "entry3"] @@ -147,3 +148,6 @@ def test_hdf5_output(self): # assert there are 6 columns ('phase', 'epoch', 'entry', 'output', 'target', 'loss') assert df_test_1[df_test_1.phase == pass_name_1].shape[1] == 6 assert df_test_2[df_test_2.phase == pass_name_2].shape[1] == 6 + # assert there are 6 columns ('phase', 'epoch', 'entry', 'output', 'target', 'loss') + assert df_test_1[df_test_1.phase == pass_name_1].shape[1] == 6 + assert df_test_2[df_test_2.phase == pass_name_2].shape[1] == 6 diff --git a/tests/utils/test_grid.py b/tests/utils/test_grid.py index 675780495..d0ded434f 100644 --- a/tests/utils/test_grid.py +++ b/tests/utils/test_grid.py @@ -1,11 +1,12 @@ import h5py import numpy as np + from deeprank2.query import (ProteinProteinInterfaceAtomicQuery, ProteinProteinInterfaceResidueQuery) from deeprank2.utils.grid import Grid, GridSettings, MapMethod -def test_residue_grid_orientation(): +def test_residue_grid_orientation(): # pylint: disable=too-many-locals coord_error_margin = 1.0 # Angstrom @@ -53,7 +54,7 @@ def test_residue_grid_orientation(): assert np.all(np.abs(grid.zs - target_zs) < coord_error_margin), f"\n{grid.zs} != \n{target_zs}" -def test_atomic_grid_orientation(): +def test_atomic_grid_orientation(): # pylint: disable=too-many-locals coord_error_margin = 1.0 # Angstrom @@ -99,3 +100,6 @@ def test_atomic_grid_orientation(): assert grid.zs.shape == target_zs.shape assert np.all(np.abs(grid.zs - target_zs) < coord_error_margin), f"\n{grid.zs} != \n{target_zs}" + + assert grid.zs.shape == target_zs.shape + assert np.all(np.abs(grid.zs - target_zs) < coord_error_margin), f"\n{grid.zs} != \n{target_zs}"