Skip to content

Commit

Permalink
fix prospector errors
Browse files Browse the repository at this point in the history
  • Loading branch information
gcroci2 committed Oct 24, 2023
1 parent 32f3e25 commit 38f26c8
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions deeprank2/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import re
import sys
import warnings
from ast import literal_eval
from typing import Dict, List, Optional, Tuple, Union

import h5py
Expand Down Expand Up @@ -229,7 +228,7 @@ def _filter_targets(self, entry_group: h5py.Group) -> bool:
for operator_string in [">", "<", "==", "<=", ">=", "!="]:
operation = operation.replace(operator_string, f"{target_value}" + operator_string)

if not eval(operation):
if not eval(operation): # pylint: disable=eval-used
return False

elif target_condition is not None:
Expand Down Expand Up @@ -413,7 +412,7 @@ def _compute_mean_std(self):


class GridDataset(DeeprankDataset):
def __init__( # pylint: disable=too-many-arguments
def __init__( # pylint: disable=too-many-arguments, too-many-locals, too-many-branches
self,
hdf5_path: Union[str, list],
subset: Optional[List[str]] = None,
Expand Down Expand Up @@ -520,8 +519,8 @@ def __init__( # pylint: disable=too-many-arguments

try:
fname, mol = self.index_entries[0]
except IndexError:
raise IndexError("No entries found in the dataset. Please check the dataset parameters.")
except IndexError as exc:
raise IndexError("No entries found in the dataset. Please check the dataset parameters.") from exc
with h5py.File(fname, 'r') as f5:
grp = f5[mol]
possible_targets = grp[targets.VALUES].keys()
Expand Down Expand Up @@ -772,7 +771,7 @@ def __init__( # noqa: MC0001, pylint: disable=too-many-arguments, too-many-local
self.features_transform = features_transform
self._check_features()

if not train:
if not train: # pylint: disable=too-many-nested-blocks
if isinstance(train_data, str):
try:
if torch.cuda.is_available():
Expand All @@ -790,7 +789,7 @@ def __init__( # noqa: MC0001, pylint: disable=too-many-arguments, too-many-local
for _, key in data["features_transform"].items():
if key['transform'] is None:
continue
key['transform'] = eval(key['transform'])
key['transform'] = eval(key['transform']) # pylint: disable=eval-used
except pickle.UnpicklingError as e:
raise ValueError("""The path provided to `train_data` is not a valid DeepRank2 pre-trained model.
Please provide a valid path to a DeepRank2 pre-trained model.""") from e
Expand All @@ -813,8 +812,8 @@ def __init__( # noqa: MC0001, pylint: disable=too-many-arguments, too-many-local

try:
fname, mol = self.index_entries[0]
except IndexError:
raise IndexError("No entries found in the dataset. Please check the dataset parameters.")
except IndexError as exc:
raise IndexError("No entries found in the dataset. Please check the dataset parameters.") from exc
with h5py.File(fname, 'r') as f5:
grp = f5[mol]
possible_targets = grp[targets.VALUES].keys()
Expand Down

0 comments on commit 38f26c8

Please sign in to comment.