Skip to content

Commit

Permalink
fix prospector errors
Browse files Browse the repository at this point in the history
  • Loading branch information
gcroci2 committed Nov 14, 2023
1 parent edab689 commit 564967c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
5 changes: 3 additions & 2 deletions tests/domain/test_aminoacidlist.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import numpy as np

from deeprank2.domain.aminoacidlist import (amino_acids, cysteine, lysine,
pyrrolysine, selenocysteine)

Expand All @@ -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}")
raise AssertionError(f"one-hot index {amino_acid.index} is occupied by both {amino_acid} and {other}") from exc
6 changes: 4 additions & 2 deletions tests/molstruct/test_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@
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:
pdb = pdb2sql(path)
try:
structure = get_structure(pdb, "101M")
finally:
pdb._close()
pdb._close() # pylint: disable=protected-access

assert structure is not None

Expand Down Expand Up @@ -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]
6 changes: 5 additions & 1 deletion tests/utils/test_exporters.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import h5py
import pandas as pd

from deeprank2.utils.exporters import (HDF5OutputExporter,
OutputExporterCollection,
ScatterPlotExporter,
Expand Down Expand Up @@ -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"]
Expand Down Expand Up @@ -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
8 changes: 6 additions & 2 deletions tests/utils/test_grid.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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}"

0 comments on commit 564967c

Please sign in to comment.