Skip to content

Commit

Permalink
deprecate cobre fetcher (nilearn#2480)
Browse files Browse the repository at this point in the history
* deprecate cobre fetcher

* fix whatsnew
jeromedockes authored May 22, 2020
1 parent 64faf99 commit 73c34c2
Showing 4 changed files with 30 additions and 3 deletions.
6 changes: 6 additions & 0 deletions doc/whats_new.rst
Original file line number Diff line number Diff line change
@@ -26,6 +26,12 @@ Fixes
some corrections regarding its description were made in the docstring.


Changes
-------

- :func:`nilearn.datasets.fetch_cobre` has been deprecated and will be
removed in release 0.9 .

0.6.2
======

15 changes: 15 additions & 0 deletions nilearn/_utils/testing.py
Original file line number Diff line number Diff line change
@@ -9,9 +9,11 @@
import urllib
import warnings
import gc
import distutils

import numpy as np
import pytest
import sklearn

from ..datasets.utils import _fetch_files

@@ -49,6 +51,19 @@ def dummy_func():
memory_usage = memory_used = None


def check_deprecation(func, match=None):
@functools.wraps(func)
def wrapped(*args, **kwargs):
if distutils.version.LooseVersion(sklearn.__version__) < '0.22':
with pytest.deprecated_call():
result = func(*args, **kwargs)
else:
with pytest.warns(FutureWarning, match=match):
result = func(*args, **kwargs)
return result
return wrapped


def assert_memory_less_than(memory_limit, tolerance,
callable_obj, *args, **kwargs):
"""Check memory consumption of a callable stays below a given limit.
6 changes: 5 additions & 1 deletion nilearn/datasets/func.py
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@
import pandas as pd
from scipy.io import loadmat
from scipy.io.matlab.miobase import MatReadError
from sklearn.utils import Bunch
from sklearn.utils import Bunch, deprecated

from .utils import (_get_dataset_dir, _fetch_files, _get_dataset_descr,
_read_md5_sum_file, _tree, _filter_columns, _fetch_file, _uncompress_file)
@@ -1490,6 +1490,10 @@ def fetch_megatrawls_netmats(dimensionality=100, timeseries='eigen_regression',
description=description)


@deprecated("'fetch_cobre' has been deprecated and will be removed "
"in release 0.9 . "
"Please consider using a different datasets or downloading it "
"with a different tool than nilearn.")
def fetch_cobre(n_subjects=10, data_dir=None, url=None, verbose=1):
"""Fetch COBRE datasets preprocessed using NIAK 0.17 under CentOS
version 6.3 with Octave version 4.0.2 and the Minc toolkit version 0.3.18.
6 changes: 4 additions & 2 deletions nilearn/datasets/tests/test_func.py
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@
from . import test_utils as tst

from nilearn.datasets import utils, func
from nilearn._utils.testing import check_deprecation

from ..utils import _get_dataset_dir

@@ -501,8 +502,9 @@ def test_fetch_cobre(tmp_path, request_mocker):
local_url = "file://" + dummy

# All subjects
cobre_data = func.fetch_cobre(n_subjects=None, data_dir=str(tmp_path),
url=local_url)
cobre_data = check_deprecation(
func.fetch_cobre, "'fetch_cobre' has been deprecated")(
n_subjects=None, data_dir=str(tmp_path), url=local_url)

phenotypic_names = ['func', 'confounds', 'phenotypic', 'description',
'desc_con', 'desc_phenotypic']

0 comments on commit 73c34c2

Please sign in to comment.