File sklearn-1.16.1.patch of Package python-nilearn

From 3ae919e5ac10e0e1db5feb7563ba70c7a0770422 Mon Sep 17 00:00:00 2001
From: Remi Gau <remi_gau@hotmail.com>
Date: Tue, 14 Jan 2025 13:53:10 +0100
Subject: [PATCH] [FIX] updates to fix some tests failures with sklearn 1.6.1
 (#5044)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
---
 nilearn/_utils/class_inspect.py                        | 1 +
 nilearn/connectome/group_sparse_cov.py                 | 7 +++++++
 nilearn/connectome/tests/test_connectivity_matrices.py | 1 +
 nilearn/connectome/tests/test_group_sparse_cov.py      | 7 +++++--
 nilearn/decoding/space_net.py                          | 8 ++++++++
 5 files changed, 22 insertions(+), 2 deletions(-)

Index: nilearn-0.11.1/nilearn/_utils/class_inspect.py
===================================================================
--- nilearn-0.11.1.orig/nilearn/_utils/class_inspect.py
+++ nilearn-0.11.1/nilearn/_utils/class_inspect.py
@@ -35,6 +35,7 @@ CHECKS_TO_SKIP_IF_IMG_INPUT = {
     "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",
Index: nilearn-0.11.1/nilearn/connectome/group_sparse_cov.py
===================================================================
--- nilearn-0.11.1.orig/nilearn/connectome/group_sparse_cov.py
+++ nilearn-0.11.1/nilearn/connectome/group_sparse_cov.py
@@ -15,6 +15,7 @@ from joblib import Memory, Parallel, del
 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 .._utils import CacheMixin, logger
@@ -618,6 +619,9 @@ class GroupSparseCovariance(CacheMixin,
             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)
 
@@ -1090,6 +1094,9 @@ class GroupSparseCovarianceCV(CacheMixin
             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
Index: nilearn-0.11.1/nilearn/connectome/tests/test_connectivity_matrices.py
===================================================================
--- nilearn-0.11.1.orig/nilearn/connectome/tests/test_connectivity_matrices.py
+++ nilearn-0.11.1/nilearn/connectome/tests/test_connectivity_matrices.py
@@ -57,6 +57,7 @@ extra_valid_checks = [
     "check_transformers_unfitted",
     "check_fit1d",
     "check_transformer_n_iter",
+    "check_estimator_sparse_tag",
 ]
 
 
Index: nilearn-0.11.1/nilearn/connectome/tests/test_group_sparse_cov.py
===================================================================
--- nilearn-0.11.1.orig/nilearn/connectome/tests/test_group_sparse_cov.py
+++ nilearn-0.11.1/nilearn/connectome/tests/test_group_sparse_cov.py
@@ -10,10 +10,13 @@ from nilearn.connectome.group_sparse_cov
 )
 
 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",
 ]
 
 
Index: nilearn-0.11.1/nilearn/decoding/space_net.py
===================================================================
--- nilearn-0.11.1.orig/nilearn/decoding/space_net.py
+++ nilearn-0.11.1/nilearn/decoding/space_net.py
@@ -630,6 +630,12 @@ class BaseSpaceNet(CacheMixin, LinearReg
     debias : 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)
@@ -736,6 +742,7 @@ class BaseSpaceNet(CacheMixin, LinearReg
         fit_intercept=True,
         screening_percentile=20.0,
         debias=False,
+        positive=False,
     ):
         self.penalty = penalty
         self.is_classif = is_classif
@@ -762,6 +769,7 @@ class BaseSpaceNet(CacheMixin, LinearReg
         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()
openSUSE Build Service is sponsored by