|
5 | 5 | """
|
6 | 6 | from __future__ import annotations
|
7 | 7 | from collections.abc import Iterable
|
| 8 | +from typing import TYPE_CHECKING, Optional |
8 | 9 | import numpy as np
|
9 | 10 | from scipy import stats
|
10 | 11 | from scipy.stats import rankdata, wilcoxon
|
|
13 | 14 | from rsatoolbox.rdm import RDMs
|
14 | 15 | from .matrix import pairwise_contrast
|
15 | 16 | from .rdm_utils import batch_to_matrices
|
16 |
| -from typing import TYPE_CHECKING, Optional |
17 | 17 | if TYPE_CHECKING:
|
18 | 18 | from numpy.typing import NDArray
|
19 | 19 |
|
@@ -117,11 +117,11 @@ def pool_rdm(rdms, method: str = 'cosine'):
|
117 | 117 | rdm_vec = np.array([_nan_rank_data(v) for v in rdm_vec])
|
118 | 118 | rdm_vec = _nan_mean(rdm_vec)
|
119 | 119 | 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!') |
121 | 121 | rdm_vec = np.array([_nan_rank_data(v) for v in rdm_vec])
|
122 | 122 | rdm_vec = _nan_mean(rdm_vec)
|
123 | 123 | 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!') |
125 | 125 | rdm_vec = np.array([_nan_rank_data(v) for v in rdm_vec])
|
126 | 126 | rdm_vec = _nan_mean(rdm_vec)
|
127 | 127 | else:
|
@@ -405,7 +405,7 @@ def bootstrap_pair_tests(evaluations):
|
405 | 405 | proportions = np.zeros((evaluations.shape[1], evaluations.shape[1]))
|
406 | 406 | while len(evaluations.shape) > 2:
|
407 | 407 | 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): |
409 | 409 | for j_model in range(i_model + 1, evaluations.shape[1]):
|
410 | 410 | proportions[i_model, j_model] = np.sum(
|
411 | 411 | evaluations[:, i_model] < evaluations[:, j_model]) \
|
@@ -663,12 +663,12 @@ def get_errorbars(model_var, evaluations, dof, error_bars='sem',
|
663 | 663 | errorbar_high = std_eval \
|
664 | 664 | * tdist.ppf(prop_cut, dof)
|
665 | 665 | 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) + '.') |
669 | 669 | limits = np.stack((errorbar_low, errorbar_high))
|
670 | 670 | if np.isnan(limits).any() or (abs(limits) == np.inf).any():
|
671 |
| - raise Exception( |
| 671 | + raise ValueError( |
672 | 672 | 'computing errorbars: Too few bootstrap samples for the ' +
|
673 | 673 | 'requested confidence interval: ' + error_bars + '.')
|
674 | 674 | return limits
|
@@ -696,7 +696,7 @@ def _dual_bootstrap(variances, n_rdm=None, n_pattern=None):
|
696 | 696 | variance = (
|
697 | 697 | (n_rdm / (n_rdm - 1)) * variances[1]
|
698 | 698 | + (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)) |
700 | 700 | * (variances[0] - variances[1] - variances[2])))
|
701 | 701 | variance = np.maximum(np.maximum(
|
702 | 702 | variance,
|
|
0 commit comments