Skip to content

Commit

Permalink
fixed darglint
Browse files Browse the repository at this point in the history
  • Loading branch information
picciama committed Apr 17, 2024
1 parent 7b7b6a1 commit 7c9da6d
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 15 deletions.
4 changes: 2 additions & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ def activate_virtualenv_in_precommit_hooks(session: Session) -> None:
session's virtual environment. This allows pre-commit to locate hooks in
that environment when invoked from git.
Args:
session: The Session object.
:param session: The Session object.
"""
assert session.bin is not None # noqa: S101

Expand Down Expand Up @@ -111,6 +110,7 @@ def precommit(session: Session) -> None:
"flake8-docstrings",
"flake8-rst-docstrings",
"isort",
"darglint",
"pep8-naming",
"pre-commit",
"pre-commit-hooks",
Expand Down
6 changes: 1 addition & 5 deletions spectrum_fundamentals/annotation/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

def match_peaks(
fragments_meta_data: List[dict],
peaks_intensity: Union[List[float], np.ndarray],
peaks_intensity: np.ndarray,
peaks_masses: np.ndarray,
tmt_n_term: int,
unmod_sequence: str,
Expand All @@ -29,10 +29,6 @@ def match_peaks(
:param charge: Precursor charge
:return: List of matched/annotated peaks
"""
# Convert peaks_intensity to numpy array if it's a list
if isinstance(peaks_intensity, list):
peaks_intensity = np.array(peaks_intensity)

start_peak = 0
no_of_peaks = len(peaks_intensity)
max_intensity = 1.0
Expand Down
6 changes: 2 additions & 4 deletions spectrum_fundamentals/metrics/fragments_ratio.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,11 @@ def count_observation_states(
:param test_state: integer for the test observation state
:param ion_mask: mask with 1s for the ions that should be counted and 0s for ions that should be ignored, \
integer array of length 174
:param xl: whether or not the function is executed with xl mode
:return: number of observation states equal to test_state per row
"""
state_boolean = observation_state == test_state
if xl:
return FragmentsRatio.count_with_ion_mask(state_boolean, ion_mask, xl=True)
else:
return FragmentsRatio.count_with_ion_mask(state_boolean, ion_mask)
return FragmentsRatio.count_with_ion_mask(state_boolean, ion_mask, xl=xl)

@staticmethod
def get_mask_observed_valid(observed_mz: scipy.sparse.csr_matrix) -> scipy.sparse.csr_matrix:
Expand Down
5 changes: 1 addition & 4 deletions spectrum_fundamentals/metrics/percolator.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,14 @@ def __init__(
all_features_flag: bool = False,
regression_method: str = "lowess",
fdr_cutoff: float = 0.01,
xl: bool = False,
):
"""Initialize a Percolator obj."""
self.metadata = metadata
self.input_type = input_type
self.all_features_flag = all_features_flag
self.regression_method = regression_method
self.fdr_cutoff = fdr_cutoff
self.xl = xl
self.xl = "CROSSLINKER_TYPE" in self.metadata.columns

super().__init__(pred_intensities, true_intensities, mz)

Expand Down Expand Up @@ -248,7 +247,6 @@ def get_target_decoy_label(reverse: bool):

def add_common_features(self):
"""Add features used by both Andromeda and Prosit feature scoring sets."""
self.xl = "CROSSLINKER_TYPE" in self.metadata.columns
if self.xl:
self.metrics_val["missedCleavages_A"] = self.metadata["SEQUENCE_A"].apply(Percolator.count_missed_cleavages)
self.metrics_val["missedCleavages_B"] = self.metadata["SEQUENCE_B"].apply(Percolator.count_missed_cleavages)
Expand Down Expand Up @@ -278,7 +276,6 @@ def add_common_features(self):

def add_percolator_metadata_columns(self):
"""Add metadata columns needed by percolator, e.g. to identify a PSM."""
self.xl = "CROSSLINKER_TYPE" in self.metadata.columns
if self.xl:
spec_id_cols = ["RAW_FILE", "SCAN_NUMBER", "MODIFIED_SEQUENCE_A", "MODIFIED_SEQUENCE_B", "PRECURSOR_CHARGE"]
self.metrics_val["Peptide"] = (
Expand Down
4 changes: 4 additions & 0 deletions spectrum_fundamentals/metrics/similarity.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def spectral_angle(
:param predicted_intensities: predicted intensities, see observed_intensities for details, array of length 174
:param charge: to filter by the peak charges, 0 means everything
:param xl: whether operating on cleavable crosslinked or linear peptides
:raises ValueError: if charge is smaller than 1 or larger than 5
:return: SA values
"""
if charge != 0:
Expand Down Expand Up @@ -209,6 +210,9 @@ def correlation(
:param predicted_intensities: predicted intensities, see observed_intensities for details, array of length 174
:param charge: to filter by the peak charges, 0 means everything
:param method: either pearson or spearman
:param xl: wheter or not to use xl mode
:raises ValueError: if charge is smaller than 1 or larger than 5
:return: calculated correlations
"""
observed_intensities_array = observed_intensities.toarray()
Expand Down

0 comments on commit 7c9da6d

Please sign in to comment.