Skip to content

Commit

Permalink
[FIX] updates to fix some tests failures with sklearn 1.6.1 (nilearn#…
Browse files Browse the repository at this point in the history
…5044)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
Remi-Gau and pre-commit-ci[bot] authored Jan 14, 2025
1 parent 44d89ca commit 3ae919e
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions nilearn/_utils/class_inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"check_estimator_sparse_array",
"check_estimator_sparse_data",
"check_estimator_sparse_matrix",
"check_estimator_sparse_tag",
"check_f_contiguous_array_estimator",
"check_fit1d",
"check_fit2d_1feature",
Expand Down
7 changes: 7 additions & 0 deletions nilearn/connectome/group_sparse_cov.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from sklearn.base import BaseEstimator
from sklearn.covariance import empirical_covariance
from sklearn.model_selection import check_cv
from sklearn.utils import check_array
from sklearn.utils.extmath import fast_logdet

from nilearn._utils import CacheMixin, fill_doc, logger
Expand Down Expand Up @@ -612,6 +613,9 @@ def fit(
the object itself. Useful for chaining operations.
"""
for x in subjects:
check_array(x, accept_sparse=False)

if self.memory is None:
self.memory = Memory(location=None)

Expand Down Expand Up @@ -1083,6 +1087,9 @@ def fit(
the object instance itself.
"""
for x in subjects:
check_array(x, accept_sparse=False)

# Empirical covariances
emp_covs, n_samples = empirical_covariances(
subjects, assume_centered=False
Expand Down
1 change: 1 addition & 0 deletions nilearn/connectome/tests/test_connectivity_matrices.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def test_check_estimator_cov_estimator(estimator):
"check_transformers_unfitted",
"check_fit1d",
"check_transformer_n_iter",
"check_estimator_sparse_tag",
]


Expand Down
7 changes: 5 additions & 2 deletions nilearn/connectome/tests/test_group_sparse_cov.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@
)

extra_valid_checks = [
"check_parameters_default_constructible",
"check_no_attributes_set_in_init",
"check_complex_data",
"check_estimator_sparse_tag",
"check_estimators_unfitted",
"check_do_not_raise_errors_in_init_or_set_params",
"check_fit1d",
"check_no_attributes_set_in_init",
"check_parameters_default_constructible",
]


Expand Down
8 changes: 8 additions & 0 deletions nilearn/decoding/space_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,12 @@ class BaseSpaceNet(CacheMixin, LinearRegression):
debias : :obj:`bool`, optional (default False)
If set, then the estimated weights maps will be debiased.
positive : bool, default=False
When set to ``True``, forces the coefficients to be positive.
This option is only supported for dense arrays.
.. versionadded:: 0.11.2dev
Attributes
----------
all_coef_ : ndarray, shape (n_l1_ratios, n_folds, n_features)
Expand Down Expand Up @@ -736,6 +742,7 @@ def __init__(
fit_intercept=True,
screening_percentile=20.0,
debias=False,
positive=False,
):
self.penalty = penalty
self.is_classif = is_classif
Expand All @@ -762,6 +769,7 @@ def __init__(
self.target_affine = target_affine
self.target_shape = target_shape
self.mask_args = mask_args
self.positive = positive

# sanity check on params
self.check_params()
Expand Down

0 comments on commit 3ae919e

Please sign in to comment.