We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Avoid documentation rot in continuous integration
I have just added a 'make check' target to the doc Makefile. It fails when there is a warning in the docs.

I have also fixed all the warnings (hours of work :( ).

I think that we should add "make check" as a test on circleci. It needs to be done after we build the docs, as the examples need to be run for warnings to pass.

@jnothman : we might be interested in porting "make check" to scikit-learn, and the CI test too, if the experiment in nilearn is successful. It's been such a fight with warnings in the scikit-learn docs.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `examples/connectivity/plot_canica_resting_state.py`
Content:
```
1 """
2 Group analysis of resting-state fMRI with ICA: CanICA
3 =====================================================
4 
5 An example applying CanICA to resting-state data. This example applies it
6 to 40 subjects of the ADHD200 datasets. Then it plots a map with all the
7 components together and an axial cut for each of the components separately.
8 
9 CanICA is an ICA method for group-level analysis of fMRI data. Compared
10 to other strategies, it brings a well-controlled group model, as well as a
11 thresholding algorithm controlling for specificity and sensitivity with
12 an explicit model of the signal. The reference papers are:
13 
14     * G. Varoquaux et al. "A group model for stable multi-subject ICA on
15       fMRI datasets", NeuroImage Vol 51 (2010), p. 288-299
16 
17     * G. Varoquaux et al. "ICA-based sparse features recovery from fMRI
18       datasets", IEEE ISBI 2010, p. 1177
19 
20 Pre-prints for both papers are available on hal
21 (http://hal.archives-ouvertes.fr)
22 """
23 
24 ####################################################################
25 # First we load the ADHD200 data
26 from nilearn import datasets
27 
28 adhd_dataset = datasets.fetch_adhd()
29 func_filenames = adhd_dataset.func  # list of 4D nifti files for each subject
30 
31 # print basic information on the dataset
32 print('First functional nifti image (4D) is at: %s' %
33       adhd_dataset.func[0])  # 4D data
34 
35 
36 ####################################################################
37 # Here we apply CanICA on the data
38 from nilearn.decomposition.canica import CanICA
39 
40 canica = CanICA(n_components=20, smoothing_fwhm=6.,
41                 memory="nilearn_cache", memory_level=5,
42                 threshold=3., verbose=10, random_state=0)
43 canica.fit(func_filenames)
44 
45 # Retrieve the independent components in brain space
46 components_img = canica.masker_.inverse_transform(canica.components_)
47 # components_img is a Nifti Image object, and can be saved to a file with
48 # the following line:
49 components_img.to_filename('canica_resting_state.nii.gz')
50 
51 
52 ####################################################################
53 # To visualize we plot the outline of all components on one figure
54 from nilearn.plotting import plot_prob_atlas
55 
56 # Plot all ICA components together
57 plot_prob_atlas(components_img, title='All ICA components')
58 
59 
60 ####################################################################
61 # Finally, we plot the map for each ICA component separately
62 from nilearn.image import iter_img
63 from nilearn.plotting import plot_stat_map, show
64 
65 for i, cur_img in enumerate(iter_img(components_img)):
66     plot_stat_map(cur_img, display_mode="z", title="IC %d" % i,
67                   cut_coords=1, colorbar=False)
68 
69 show()
70
```

Path: `examples/connectivity/plot_connectivity_measures.py`
Content:
```
1 """
2 Comparing different functional connectivity measures
3 ====================================================
4 
5 This example compares different measures of functional connectivity between
6 regions of interest : correlation, partial correlation, as well as a measure
7 called tangent. The resulting connectivity coefficients are used to
8 classify ADHD vs control subjects and the tangent measure outperforms the
9 standard measures.
10 
11 """
12 
13 # Fetch dataset
14 import nilearn.datasets
15 atlas = nilearn.datasets.fetch_atlas_msdl()
16 dataset = nilearn.datasets.fetch_adhd()
17 
18 
19 ######################################################################
20 # Extract regions time series signals
21 import nilearn.input_data
22 masker = nilearn.input_data.NiftiMapsMasker(
23     atlas.maps, resampling_target="maps", detrend=True,
24     low_pass=None, high_pass=None, t_r=2.5, standardize=False,
25     memory='nilearn_cache', memory_level=1)
26 subjects = []
27 sites = []
28 adhds = []
29 for func_file, phenotypic in zip(dataset.func, dataset.phenotypic):
30     # keep only 3 sites, to save computation time
31     if phenotypic['site'] in [b'"NYU"', b'"OHSU"', b'"NeuroImage"']:
32         time_series = masker.fit_transform(func_file)
33         subjects.append(time_series)
34         sites.append(phenotypic['site'])
35         adhds.append(phenotypic['adhd'])  # ADHD/control label
36 
37 
38 ######################################################################
39 # Estimate connectivity
40 import nilearn.connectome
41 kinds = ['tangent', 'partial correlation', 'correlation']
42 individual_connectivity_matrices = {}
43 mean_connectivity_matrix = {}
44 for kind in kinds:
45     conn_measure = nilearn.connectome.ConnectivityMeasure(kind=kind)
46     individual_connectivity_matrices[kind] = conn_measure.fit_transform(
47         subjects)
48     # Compute the mean connectivity
49     if kind == 'tangent':
50         mean_connectivity_matrix[kind] = conn_measure.mean_
51     else:
52         mean_connectivity_matrix[kind] = \
53             individual_connectivity_matrices[kind].mean(axis=0)
54 
55 
56 ######################################################################
57 # Plot the mean connectome
58 import numpy as np
59 import nilearn.plotting
60 labels = np.recfromcsv(atlas.labels)
61 region_coords = labels[['x', 'y', 'z']].tolist()
62 for kind in kinds:
63     nilearn.plotting.plot_connectome(mean_connectivity_matrix[kind],
64                                      region_coords, edge_threshold='98%',
65                                      title=kind)
66 
67 
68 ######################################################################
69 # Use the connectivity coefficients to classify ADHD vs controls
70 from sklearn.svm import LinearSVC
71 from sklearn.cross_validation import StratifiedKFold, cross_val_score
72 classes = ['{0}{1}'.format(site, adhd) for site, adhd in zip(sites, adhds)]
73 print('Classification accuracy:')
74 mean_scores = []
75 cv = StratifiedKFold(classes, n_folds=3)
76 for kind in kinds:
77     svc = LinearSVC()
78     # Transform the connectivity matrices to 1D arrays
79     coonectivity_coefs = nilearn.connectome.sym_to_vec(
80         individual_connectivity_matrices[kind])
81     cv_scores = cross_val_score(svc, coonectivity_coefs,
82                                 adhds, cv=cv, scoring='accuracy')
83     print('%20s score: %1.2f +- %1.2f' % (kind, cv_scores.mean(),
84                                           cv_scores.std()))
85     mean_scores.append(cv_scores.mean())
86 
87 
88 ######################################################################
89 # Display the classification scores
90 import matplotlib.pyplot as plt
91 plt.figure(figsize=(6, 4))
92 positions = np.arange(len(kinds)) * .1 + .1
93 plt.barh(positions, mean_scores, align='center', height=.05)
94 yticks = [kind.replace(' ', '\n') for kind in kinds]
95 plt.yticks(positions, yticks)
96 plt.xlabel('Classification accuracy')
97 plt.grid(True)
98 plt.tight_layout()
99 plt.show()
100
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/examples/connectivity/plot_canica_resting_state.py b/examples/connectivity/plot_canica_resting_state.py
--- a/examples/connectivity/plot_canica_resting_state.py
+++ b/examples/connectivity/plot_canica_resting_state.py
@@ -25,7 +25,7 @@
 # First we load the ADHD200 data
 from nilearn import datasets
 
-adhd_dataset = datasets.fetch_adhd()
+adhd_dataset = datasets.fetch_adhd(n_subjects=30)
 func_filenames = adhd_dataset.func  # list of 4D nifti files for each subject
 
 # print basic information on the dataset
diff --git a/examples/connectivity/plot_connectivity_measures.py b/examples/connectivity/plot_connectivity_measures.py
--- a/examples/connectivity/plot_connectivity_measures.py
+++ b/examples/connectivity/plot_connectivity_measures.py
@@ -13,7 +13,7 @@
 # Fetch dataset
 import nilearn.datasets
 atlas = nilearn.datasets.fetch_atlas_msdl()
-dataset = nilearn.datasets.fetch_adhd()
+dataset = nilearn.datasets.fetch_adhd(n_subjects=30)
 
 
 ######################################################################

{"golden_diff": "diff --git a/examples/connectivity/plot_canica_resting_state.py b/examples/connectivity/plot_canica_resting_state.py\n--- a/examples/connectivity/plot_canica_resting_state.py\n+++ b/examples/connectivity/plot_canica_resting_state.py\n@@ -25,7 +25,7 @@\n # First we load the ADHD200 data\n from nilearn import datasets\n \n-adhd_dataset = datasets.fetch_adhd()\n+adhd_dataset = datasets.fetch_adhd(n_subjects=30)\n func_filenames = adhd_dataset.func  # list of 4D nifti files for each subject\n \n # print basic information on the dataset\ndiff --git a/examples/connectivity/plot_connectivity_measures.py b/examples/connectivity/plot_connectivity_measures.py\n--- a/examples/connectivity/plot_connectivity_measures.py\n+++ b/examples/connectivity/plot_connectivity_measures.py\n@@ -13,7 +13,7 @@\n # Fetch dataset\n import nilearn.datasets\n atlas = nilearn.datasets.fetch_atlas_msdl()\n-dataset = nilearn.datasets.fetch_adhd()\n+dataset = nilearn.datasets.fetch_adhd(n_subjects=30)\n \n \n ######################################################################\n", "issue": "Avoid documentation rot in continuous integration\nI have just added a 'make check' target to the doc Makefile. It fails when there is a warning in the docs.\n\nI have also fixed all the warnings (hours of work :( ).\n\nI think that we should add \"make check\" as a test on circleci. It needs to be done after we build the docs, as the examples need to be run for warnings to pass.\n\n@jnothman : we might be interested in porting \"make check\" to scikit-learn, and the CI test too, if the experiment in nilearn is successful. It's been such a fight with warnings in the scikit-learn docs.\n\n", "before_files": [{"content": "\"\"\"\nGroup analysis of resting-state fMRI with ICA: CanICA\n=====================================================\n\nAn example applying CanICA to resting-state data. This example applies it\nto 40 subjects of the ADHD200 datasets. Then it plots a map with all the\ncomponents together and an axial cut for each of the components separately.\n\nCanICA is an ICA method for group-level analysis of fMRI data. Compared\nto other strategies, it brings a well-controlled group model, as well as a\nthresholding algorithm controlling for specificity and sensitivity with\nan explicit model of the signal. The reference papers are:\n\n    * G. Varoquaux et al. \"A group model for stable multi-subject ICA on\n      fMRI datasets\", NeuroImage Vol 51 (2010), p. 288-299\n\n    * G. Varoquaux et al. \"ICA-based sparse features recovery from fMRI\n      datasets\", IEEE ISBI 2010, p. 1177\n\nPre-prints for both papers are available on hal\n(http://hal.archives-ouvertes.fr)\n\"\"\"\n\n####################################################################\n# First we load the ADHD200 data\nfrom nilearn import datasets\n\nadhd_dataset = datasets.fetch_adhd()\nfunc_filenames = adhd_dataset.func  # list of 4D nifti files for each subject\n\n# print basic information on the dataset\nprint('First functional nifti image (4D) is at: %s' %\n      adhd_dataset.func[0])  # 4D data\n\n\n####################################################################\n# Here we apply CanICA on the data\nfrom nilearn.decomposition.canica import CanICA\n\ncanica = CanICA(n_components=20, smoothing_fwhm=6.,\n                memory=\"nilearn_cache\", memory_level=5,\n                threshold=3., verbose=10, random_state=0)\ncanica.fit(func_filenames)\n\n# Retrieve the independent components in brain space\ncomponents_img = canica.masker_.inverse_transform(canica.components_)\n# components_img is a Nifti Image object, and can be saved to a file with\n# the following line:\ncomponents_img.to_filename('canica_resting_state.nii.gz')\n\n\n####################################################################\n# To visualize we plot the outline of all components on one figure\nfrom nilearn.plotting import plot_prob_atlas\n\n# Plot all ICA components together\nplot_prob_atlas(components_img, title='All ICA components')\n\n\n####################################################################\n# Finally, we plot the map for each ICA component separately\nfrom nilearn.image import iter_img\nfrom nilearn.plotting import plot_stat_map, show\n\nfor i, cur_img in enumerate(iter_img(components_img)):\n    plot_stat_map(cur_img, display_mode=\"z\", title=\"IC %d\" % i,\n                  cut_coords=1, colorbar=False)\n\nshow()\n", "path": "examples/connectivity/plot_canica_resting_state.py"}, {"content": "\"\"\"\nComparing different functional connectivity measures\n====================================================\n\nThis example compares different measures of functional connectivity between\nregions of interest : correlation, partial correlation, as well as a measure\ncalled tangent. The resulting connectivity coefficients are used to\nclassify ADHD vs control subjects and the tangent measure outperforms the\nstandard measures.\n\n\"\"\"\n\n# Fetch dataset\nimport nilearn.datasets\natlas = nilearn.datasets.fetch_atlas_msdl()\ndataset = nilearn.datasets.fetch_adhd()\n\n\n######################################################################\n# Extract regions time series signals\nimport nilearn.input_data\nmasker = nilearn.input_data.NiftiMapsMasker(\n    atlas.maps, resampling_target=\"maps\", detrend=True,\n    low_pass=None, high_pass=None, t_r=2.5, standardize=False,\n    memory='nilearn_cache', memory_level=1)\nsubjects = []\nsites = []\nadhds = []\nfor func_file, phenotypic in zip(dataset.func, dataset.phenotypic):\n    # keep only 3 sites, to save computation time\n    if phenotypic['site'] in [b'\"NYU\"', b'\"OHSU\"', b'\"NeuroImage\"']:\n        time_series = masker.fit_transform(func_file)\n        subjects.append(time_series)\n        sites.append(phenotypic['site'])\n        adhds.append(phenotypic['adhd'])  # ADHD/control label\n\n\n######################################################################\n# Estimate connectivity\nimport nilearn.connectome\nkinds = ['tangent', 'partial correlation', 'correlation']\nindividual_connectivity_matrices = {}\nmean_connectivity_matrix = {}\nfor kind in kinds:\n    conn_measure = nilearn.connectome.ConnectivityMeasure(kind=kind)\n    individual_connectivity_matrices[kind] = conn_measure.fit_transform(\n        subjects)\n    # Compute the mean connectivity\n    if kind == 'tangent':\n        mean_connectivity_matrix[kind] = conn_measure.mean_\n    else:\n        mean_connectivity_matrix[kind] = \\\n            individual_connectivity_matrices[kind].mean(axis=0)\n\n\n######################################################################\n# Plot the mean connectome\nimport numpy as np\nimport nilearn.plotting\nlabels = np.recfromcsv(atlas.labels)\nregion_coords = labels[['x', 'y', 'z']].tolist()\nfor kind in kinds:\n    nilearn.plotting.plot_connectome(mean_connectivity_matrix[kind],\n                                     region_coords, edge_threshold='98%',\n                                     title=kind)\n\n\n######################################################################\n# Use the connectivity coefficients to classify ADHD vs controls\nfrom sklearn.svm import LinearSVC\nfrom sklearn.cross_validation import StratifiedKFold, cross_val_score\nclasses = ['{0}{1}'.format(site, adhd) for site, adhd in zip(sites, adhds)]\nprint('Classification accuracy:')\nmean_scores = []\ncv = StratifiedKFold(classes, n_folds=3)\nfor kind in kinds:\n    svc = LinearSVC()\n    # Transform the connectivity matrices to 1D arrays\n    coonectivity_coefs = nilearn.connectome.sym_to_vec(\n        individual_connectivity_matrices[kind])\n    cv_scores = cross_val_score(svc, coonectivity_coefs,\n                                adhds, cv=cv, scoring='accuracy')\n    print('%20s score: %1.2f +- %1.2f' % (kind, cv_scores.mean(),\n                                          cv_scores.std()))\n    mean_scores.append(cv_scores.mean())\n\n\n######################################################################\n# Display the classification scores\nimport matplotlib.pyplot as plt\nplt.figure(figsize=(6, 4))\npositions = np.arange(len(kinds)) * .1 + .1\nplt.barh(positions, mean_scores, align='center', height=.05)\nyticks = [kind.replace(' ', '\\n') for kind in kinds]\nplt.yticks(positions, yticks)\nplt.xlabel('Classification accuracy')\nplt.grid(True)\nplt.tight_layout()\nplt.show()\n", "path": "examples/connectivity/plot_connectivity_measures.py"}], "after_files": [{"content": "\"\"\"\nGroup analysis of resting-state fMRI with ICA: CanICA\n=====================================================\n\nAn example applying CanICA to resting-state data. This example applies it\nto 40 subjects of the ADHD200 datasets. Then it plots a map with all the\ncomponents together and an axial cut for each of the components separately.\n\nCanICA is an ICA method for group-level analysis of fMRI data. Compared\nto other strategies, it brings a well-controlled group model, as well as a\nthresholding algorithm controlling for specificity and sensitivity with\nan explicit model of the signal. The reference papers are:\n\n    * G. Varoquaux et al. \"A group model for stable multi-subject ICA on\n      fMRI datasets\", NeuroImage Vol 51 (2010), p. 288-299\n\n    * G. Varoquaux et al. \"ICA-based sparse features recovery from fMRI\n      datasets\", IEEE ISBI 2010, p. 1177\n\nPre-prints for both papers are available on hal\n(http://hal.archives-ouvertes.fr)\n\"\"\"\n\n####################################################################\n# First we load the ADHD200 data\nfrom nilearn import datasets\n\nadhd_dataset = datasets.fetch_adhd(n_subjects=30)\nfunc_filenames = adhd_dataset.func  # list of 4D nifti files for each subject\n\n# print basic information on the dataset\nprint('First functional nifti image (4D) is at: %s' %\n      adhd_dataset.func[0])  # 4D data\n\n\n####################################################################\n# Here we apply CanICA on the data\nfrom nilearn.decomposition.canica import CanICA\n\ncanica = CanICA(n_components=20, smoothing_fwhm=6.,\n                memory=\"nilearn_cache\", memory_level=5,\n                threshold=3., verbose=10, random_state=0)\ncanica.fit(func_filenames)\n\n# Retrieve the independent components in brain space\ncomponents_img = canica.masker_.inverse_transform(canica.components_)\n# components_img is a Nifti Image object, and can be saved to a file with\n# the following line:\ncomponents_img.to_filename('canica_resting_state.nii.gz')\n\n\n####################################################################\n# To visualize we plot the outline of all components on one figure\nfrom nilearn.plotting import plot_prob_atlas\n\n# Plot all ICA components together\nplot_prob_atlas(components_img, title='All ICA components')\n\n\n####################################################################\n# Finally, we plot the map for each ICA component separately\nfrom nilearn.image import iter_img\nfrom nilearn.plotting import plot_stat_map, show\n\nfor i, cur_img in enumerate(iter_img(components_img)):\n    plot_stat_map(cur_img, display_mode=\"z\", title=\"IC %d\" % i,\n                  cut_coords=1, colorbar=False)\n\nshow()\n", "path": "examples/connectivity/plot_canica_resting_state.py"}, {"content": "\"\"\"\nComparing different functional connectivity measures\n====================================================\n\nThis example compares different measures of functional connectivity between\nregions of interest : correlation, partial correlation, as well as a measure\ncalled tangent. The resulting connectivity coefficients are used to\nclassify ADHD vs control subjects and the tangent measure outperforms the\nstandard measures.\n\n\"\"\"\n\n# Fetch dataset\nimport nilearn.datasets\natlas = nilearn.datasets.fetch_atlas_msdl()\ndataset = nilearn.datasets.fetch_adhd(n_subjects=30)\n\n\n######################################################################\n# Extract regions time series signals\nimport nilearn.input_data\nmasker = nilearn.input_data.NiftiMapsMasker(\n    atlas.maps, resampling_target=\"maps\", detrend=True,\n    low_pass=None, high_pass=None, t_r=2.5, standardize=False,\n    memory='nilearn_cache', memory_level=1)\nsubjects = []\nsites = []\nadhds = []\nfor func_file, phenotypic in zip(dataset.func, dataset.phenotypic):\n    # keep only 3 sites, to save computation time\n    if phenotypic['site'] in [b'\"NYU\"', b'\"OHSU\"', b'\"NeuroImage\"']:\n        time_series = masker.fit_transform(func_file)\n        subjects.append(time_series)\n        sites.append(phenotypic['site'])\n        adhds.append(phenotypic['adhd'])  # ADHD/control label\n\n\n######################################################################\n# Estimate connectivity\nimport nilearn.connectome\nkinds = ['tangent', 'partial correlation', 'correlation']\nindividual_connectivity_matrices = {}\nmean_connectivity_matrix = {}\nfor kind in kinds:\n    conn_measure = nilearn.connectome.ConnectivityMeasure(kind=kind)\n    individual_connectivity_matrices[kind] = conn_measure.fit_transform(\n        subjects)\n    # Compute the mean connectivity\n    if kind == 'tangent':\n        mean_connectivity_matrix[kind] = conn_measure.mean_\n    else:\n        mean_connectivity_matrix[kind] = \\\n            individual_connectivity_matrices[kind].mean(axis=0)\n\n\n######################################################################\n# Plot the mean connectome\nimport numpy as np\nimport nilearn.plotting\nlabels = np.recfromcsv(atlas.labels)\nregion_coords = labels[['x', 'y', 'z']].tolist()\nfor kind in kinds:\n    nilearn.plotting.plot_connectome(mean_connectivity_matrix[kind],\n                                     region_coords, edge_threshold='98%',\n                                     title=kind)\n\n\n######################################################################\n# Use the connectivity coefficients to classify ADHD vs controls\nfrom sklearn.svm import LinearSVC\nfrom sklearn.cross_validation import StratifiedKFold, cross_val_score\nclasses = ['{0}{1}'.format(site, adhd) for site, adhd in zip(sites, adhds)]\nprint('Classification accuracy:')\nmean_scores = []\ncv = StratifiedKFold(classes, n_folds=3)\nfor kind in kinds:\n    svc = LinearSVC()\n    # Transform the connectivity matrices to 1D arrays\n    coonectivity_coefs = nilearn.connectome.sym_to_vec(\n        individual_connectivity_matrices[kind])\n    cv_scores = cross_val_score(svc, coonectivity_coefs,\n                                adhds, cv=cv, scoring='accuracy')\n    print('%20s score: %1.2f +- %1.2f' % (kind, cv_scores.mean(),\n                                          cv_scores.std()))\n    mean_scores.append(cv_scores.mean())\n\n\n######################################################################\n# Display the classification scores\nimport matplotlib.pyplot as plt\nplt.figure(figsize=(6, 4))\npositions = np.arange(len(kinds)) * .1 + .1\nplt.barh(positions, mean_scores, align='center', height=.05)\nyticks = [kind.replace(' ', '\\n') for kind in kinds]\nplt.yticks(positions, yticks)\nplt.xlabel('Classification accuracy')\nplt.grid(True)\nplt.tight_layout()\nplt.show()\n", "path": "examples/connectivity/plot_connectivity_measures.py"}]}