Skip to content

Commit b4abc4d

Browse files
committed
fixing codefactor suggestions
1 parent 722ef8c commit b4abc4d

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/rsatoolbox/inference/result.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,10 @@ def get_errorbars(self, eb_type='sem', test_type='t-test'):
253253
ci = self.get_ci(ci_percent, test_type)
254254
means = self.get_means()
255255
errorbar_low = -(ci[0] - means)
256-
errorbar_high = (ci[1] - means)
256+
errorbar_high = ci[1] - means
257257
limits = np.concatenate((errorbar_low, errorbar_high))
258258
if np.isnan(limits).any() or (abs(limits) == np.inf).any():
259-
raise Exception(
259+
raise RuntimeError(
260260
'plot_model_comparison: Too few bootstrap samples for ' +
261261
'the requested confidence interval: ' + eb_type + '.')
262262
return (errorbar_low, errorbar_high)

src/rsatoolbox/util/inference_util.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"""
66
from __future__ import annotations
77
from collections.abc import Iterable
8+
from typing import TYPE_CHECKING, Optional
89
import numpy as np
910
from scipy import stats
1011
from scipy.stats import rankdata, wilcoxon
@@ -13,7 +14,6 @@
1314
from rsatoolbox.rdm import RDMs
1415
from .matrix import pairwise_contrast
1516
from .rdm_utils import batch_to_matrices
16-
from typing import TYPE_CHECKING, Optional
1717
if TYPE_CHECKING:
1818
from numpy.typing import NDArray
1919

@@ -117,11 +117,11 @@ def pool_rdm(rdms, method: str = 'cosine'):
117117
rdm_vec = np.array([_nan_rank_data(v) for v in rdm_vec])
118118
rdm_vec = _nan_mean(rdm_vec)
119119
elif method in ('kendall', 'tau-b'):
120-
Warning('Noise ceiling for tau based on averaged ranks!')
120+
raise Warning('Noise ceiling for tau based on averaged ranks!')
121121
rdm_vec = np.array([_nan_rank_data(v) for v in rdm_vec])
122122
rdm_vec = _nan_mean(rdm_vec)
123123
elif method == 'tau-a':
124-
Warning('Noise ceiling for tau based on averaged ranks!')
124+
raise Warning('Noise ceiling for tau based on averaged ranks!')
125125
rdm_vec = np.array([_nan_rank_data(v) for v in rdm_vec])
126126
rdm_vec = _nan_mean(rdm_vec)
127127
else:
@@ -405,7 +405,7 @@ def bootstrap_pair_tests(evaluations):
405405
proportions = np.zeros((evaluations.shape[1], evaluations.shape[1]))
406406
while len(evaluations.shape) > 2:
407407
evaluations = np.mean(evaluations, axis=-1)
408-
for i_model in range(evaluations.shape[1]-1):
408+
for i_model in range(evaluations.shape[1] - 1):
409409
for j_model in range(i_model + 1, evaluations.shape[1]):
410410
proportions[i_model, j_model] = np.sum(
411411
evaluations[:, i_model] < evaluations[:, j_model]) \
@@ -663,12 +663,12 @@ def get_errorbars(model_var, evaluations, dof, error_bars='sem',
663663
errorbar_high = std_eval \
664664
* tdist.ppf(prop_cut, dof)
665665
else:
666-
raise Exception('computing errorbars: Argument ' +
667-
'error_bars is incorrectly defined as '
668-
+ str(error_bars) + '.')
666+
raise ValueError('computing errorbars: Argument ' +
667+
'error_bars is incorrectly defined as '
668+
+ str(error_bars) + '.')
669669
limits = np.stack((errorbar_low, errorbar_high))
670670
if np.isnan(limits).any() or (abs(limits) == np.inf).any():
671-
raise Exception(
671+
raise ValueError(
672672
'computing errorbars: Too few bootstrap samples for the ' +
673673
'requested confidence interval: ' + error_bars + '.')
674674
return limits
@@ -696,7 +696,7 @@ def _dual_bootstrap(variances, n_rdm=None, n_pattern=None):
696696
variance = (
697697
(n_rdm / (n_rdm - 1)) * variances[1]
698698
+ (n_pattern / (n_pattern - 1)) * variances[2]
699-
- ((n_pattern*n_rdm / (n_pattern - 1) / (n_rdm - 1))
699+
- ((n_pattern * n_rdm / (n_pattern - 1) / (n_rdm - 1))
700700
* (variances[0] - variances[1] - variances[2])))
701701
variance = np.maximum(np.maximum(
702702
variance,

0 commit comments

Comments
 (0)