Skip to content

Commit 8a326f8

Browse files
nelson-liuogrisel
authored andcommitted
Updated examples and tests that use scipy's lena
scipy.misc.lena will be removed in scipy version 0.17. This changes the example to use scipy.misc.face instead.
1 parent ac7450a commit 8a326f8

File tree

14 files changed

+431
-219
lines changed

14 files changed

+431
-219
lines changed

circle.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
1+
dependencies:
2+
cache_directories:
3+
- "~/scikit_learn_data"
4+
- "~/scikit-learn.github.io"
5+
- "~/download"
6+
# Check whether the doc build is required, install build dependencies and
7+
# run sphinx to build the doc.
8+
override:
9+
- ./continuous_integration/circle/build_doc.sh
10+
test:
11+
# Grep error on the documentation
12+
override:
13+
- cat ~/log.txt && if grep -q "Traceback (most recent call last):" ~/log.txt; then false; else true; fi
114
general:
2-
# Restric the build to the branch master only
3-
branches:
4-
only:
5-
- master
15+
# Open the doc to the API
16+
artifacts:
17+
- "doc/_build/html"
18+
- "~/log.txt"
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
set -x
2+
set -e
3+
4+
# Introspect the commit to know whether or not we should skip building the
5+
# documentation: a pull request that does not change any file in doc/ or
6+
# examples/ folder should be skipped unless the "[doc: build]" is found the
7+
# commit message.
8+
BUILD_DOC=`python continuous_integration/circle/check_build_doc.py`
9+
echo -e $BUILD_DOC
10+
if [[ $BUILD_DOC == "SKIP:"* ]]; then
11+
touch ~/log.txt # the "test" segment needs that file
12+
exit 0
13+
fi
14+
15+
# Installing required system packages to support the rendering of match
16+
# notation in the HTML documentation
17+
sudo -E apt-get -yq update
18+
sudo -E apt-get -yq remove texlive-binaries --purge
19+
sudo -E apt-get -yq --no-install-suggests --no-install-recommends --force-yes \
20+
install dvipng texlive-latex-base texlive-latex-extra
21+
22+
# deactivate circleci virtualenv and setup a miniconda env instead
23+
if [[ `type -t deactivate` ]]; then
24+
deactivate
25+
fi
26+
27+
# Install dependencies with miniconda
28+
pushd .
29+
cd
30+
mkdir -p download
31+
cd download
32+
echo "Cached in $HOME/download :"
33+
ls -l
34+
if [[ ! -f miniconda.sh ]]
35+
then
36+
wget https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh \
37+
-O miniconda.sh
38+
fi
39+
chmod +x miniconda.sh && ./miniconda.sh -b -p $HOME/miniconda
40+
cd ..
41+
export PATH="$HOME/miniconda/bin:$PATH"
42+
conda update --yes --quiet conda
43+
popd
44+
45+
# Configure the conda environment and put it in the path using the
46+
# provided versions
47+
conda create -n testenv --yes --quiet python numpy scipy \
48+
cython nose coverage matplotlib sphinx pillow
49+
source /home/ubuntu/miniconda/envs/testenv/bin/activate testenv
50+
51+
# Build and install scikit-learn in dev mode
52+
python setup.py develop
53+
54+
# The pipefail is requested to propagate exit code
55+
set -o pipefail && cd doc && make html 2>&1 | tee ~/log.txt
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
"""Check whether we or not we should build the documentation
2+
3+
If the last commit message has a "[doc skip]" marker, do not build
4+
the doc. On the contrary if a "[doc build]" marker is found, build the doc
5+
instead of relying on the subsequent rules.
6+
7+
We always build the documentation for jobs that are not related to a specific
8+
PR (e.g. a merge to master or a maintenance branch).
9+
10+
If this is a PR, check that if there are some files in this PR that are under
11+
the "doc/" or "examples/" folders, otherwise skip.
12+
13+
If the introspection of the current commit fails for any reason, the default
14+
behavior is to build the documentation.
15+
16+
"""
17+
import sys
18+
import os
19+
from subprocess import check_output, CalledProcessError
20+
21+
22+
def exit(msg="", skip=False):
23+
print("%s: %s" % ("SKIP" if skip else "BUILD", msg))
24+
sys.exit(0)
25+
26+
# Introspect the message for the commit that triggered the build
27+
commit = os.environ.get('CIRCLE_SHA1')
28+
if not commit:
29+
exit("undefined CIRCLE_SHA1 variable")
30+
try:
31+
commit_msg = check_output("git log --format=%B -n 1".split() + [commit])
32+
commit_msg = commit_msg.decode('utf-8')
33+
except CalledProcessError:
34+
exit("failed to introspect commit message for %s" % commit)
35+
36+
if "[doc skip]" in commit_msg:
37+
exit("[doc skip] marker found", skip=True)
38+
elif "[doc build]" in commit_msg:
39+
exit("[doc build] marker found")
40+
41+
# Check whether this commit is part of a pull request or not
42+
pr_url = os.environ.get('CI_PULL_REQUEST')
43+
if not pr_url:
44+
# The documentation should be always built when executed from one of the
45+
# main branches
46+
exit("not a pull request")
47+
48+
# Introspect the list of files changed by all the commits in this PR.
49+
# Hardcode the assumption that this is a PR to origin/master of this repo
50+
# as apparently there is way to reliably get the target of a PR with circle
51+
# ci
52+
git_range = "origin/master..%s" % commit
53+
try:
54+
filenames = check_output("git diff --name-only".split() + [git_range])
55+
except CalledProcessError:
56+
exit("git introspection failed.")
57+
filenames = filenames.decode('utf-8').split()
58+
for filename in filenames:
59+
if filename.startswith(u'doc/') or filename.startswith(u'examples/'):
60+
exit("detected doc impacting file modified by PR at %s" % filename)
61+
62+
# This PR does not seem to have any documentation related file changed.
63+
msg = "no doc impacting files detected:\n" + u"\n".join(filenames)
64+
exit(msg, skip=True)

doc/modules/clustering.rst

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -464,15 +464,15 @@ function of the gradient of the image.
464464
* :ref:`example_cluster_plot_segmentation_toy.py`: Segmenting objects
465465
from a noisy background using spectral clustering.
466466

467-
* :ref:`example_cluster_plot_lena_segmentation.py`: Spectral clustering
468-
to split the image of lena in regions.
467+
* :ref:`example_cluster_plot_face_segmentation.py`: Spectral clustering
468+
to split the image of the raccoon face in regions.
469469

470-
.. |lena_kmeans| image:: ../auto_examples/cluster/images/plot_lena_segmentation_001.png
471-
:target: ../auto_examples/cluster/plot_lena_segmentation.html
470+
.. |face_kmeans| image:: ../auto_examples/cluster/images/plot_face_segmentation_001.png
471+
:target: ../auto_examples/cluster/plot_face_segmentation.html
472472
:scale: 65
473473

474-
.. |lena_discretize| image:: ../auto_examples/cluster/images/plot_lena_segmentation_002.png
475-
:target: ../auto_examples/cluster/plot_lena_segmentation.html
474+
.. |face_discretize| image:: ../auto_examples/cluster/images/plot_face_segmentation_002.png
475+
:target: ../auto_examples/cluster/plot_face_segmentation.html
476476
:scale: 65
477477

478478
Different label assignment strategies
@@ -490,7 +490,7 @@ geometrical shape.
490490
===================================== =====================================
491491
``assign_labels="kmeans"`` ``assign_labels="discretize"``
492492
===================================== =====================================
493-
|lena_kmeans| |lena_discretize|
493+
|face_kmeans| |face_discretize|
494494
===================================== =====================================
495495

496496

@@ -619,12 +619,12 @@ merging to nearest neighbors as in :ref:`this example
619619
<example_cluster_plot_agglomerative_clustering.py>`, or
620620
using :func:`sklearn.feature_extraction.image.grid_to_graph` to
621621
enable only merging of neighboring pixels on an image, as in the
622-
:ref:`Lena <example_cluster_plot_lena_ward_segmentation.py>` example.
622+
:ref:`raccoon face <example_cluster_plot_face_ward_segmentation.py>` example.
623623

624624
.. topic:: Examples:
625625

626-
* :ref:`example_cluster_plot_lena_ward_segmentation.py`: Ward clustering
627-
to split the image of lena in regions.
626+
* :ref:`example_cluster_plot_face_ward_segmentation.py`: Ward clustering
627+
to split the image of a raccoon face in regions.
628628

629629
* :ref:`example_cluster_plot_ward_structured_vs_unstructured.py`: Example of
630630
Ward algorithm on a swiss-roll, comparison of structured approaches
@@ -1401,5 +1401,3 @@ Drawbacks
14011401

14021402
* :ref:`example_cluster_plot_kmeans_silhouette_analysis.py` : In this example
14031403
the silhouette analysis is used to choose an optimal value for n_clusters.
1404-
1405-

doc/modules/decomposition.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ sparse coding step that shares the same implementation with all dictionary
451451
learning objects (see :ref:`SparseCoder`).
452452

453453
The following image shows how a dictionary learned from 4x4 pixel image patches
454-
extracted from part of the image of Lena looks like.
454+
extracted from part of the image of a raccoon face looks like.
455455

456456

457457
.. figure:: ../auto_examples/decomposition/images/plot_image_denoising_001.png

doc/modules/feature_extraction.rst

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -748,17 +748,17 @@ An interesting development of using a :class:`HashingVectorizer` is the ability
748748
to perform `out-of-core`_ scaling. This means that we can learn from data that
749749
does not fit into the computer's main memory.
750750

751-
.. _out-of-core: http://en.wikipedia.org/wiki/Out-of-core_algorithm
751+
.. _out-of-core: http://en.wikipedia.org/wiki/Out-of-core_algorithm
752752

753-
A strategy to implement out-of-core scaling is to stream data to the estimator
753+
A strategy to implement out-of-core scaling is to stream data to the estimator
754754
in mini-batches. Each mini-batch is vectorized using :class:`HashingVectorizer`
755755
so as to guarantee that the input space of the estimator has always the same
756756
dimensionality. The amount of memory used at any time is thus bounded by the
757757
size of a mini-batch. Although there is no limit to the amount of data that can
758758
be ingested using such an approach, from a practical point of view the learning
759759
time is often limited by the CPU time one wants to spend on the task.
760760

761-
For a full-fledged example of out-of-core scaling in a text classification
761+
For a full-fledged example of out-of-core scaling in a text classification
762762
task see :ref:`example_applications_plot_out_of_core_classification.py`.
763763

764764
Customizing the vectorizer classes
@@ -892,8 +892,8 @@ features or samples. For instance Ward clustering
892892
(:ref:`hierarchical_clustering`) can cluster together only neighboring pixels
893893
of an image, thus forming contiguous patches:
894894

895-
.. figure:: ../auto_examples/cluster/images/plot_lena_ward_segmentation_001.png
896-
:target: ../auto_examples/cluster/plot_lena_ward_segmentation.html
895+
.. figure:: ../auto_examples/cluster/images/plot_face_ward_segmentation_001.png
896+
:target: ../auto_examples/cluster/plot_face_ward_segmentation.html
897897
:align: center
898898
:scale: 40
899899

@@ -911,9 +911,8 @@ or similarity matrices.
911911

912912
.. note:: **Examples**
913913

914-
* :ref:`example_cluster_plot_lena_ward_segmentation.py`
914+
* :ref:`example_cluster_plot_face_ward_segmentation.py`
915915

916916
* :ref:`example_cluster_plot_segmentation_toy.py`
917917

918918
* :ref:`example_cluster_plot_feature_agglomeration_vs_univariate_selection.py`
919-

doc/themes/scikit-learn/layout.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@
160160
<img src="_images/plot_gmm_pdf.png"></a>
161161
</div>
162162
<div class="item">
163-
<a href="{{ pathto('auto_examples/cluster/plot_lena_ward_segmentation') }}">
164-
<img src="_images/plot_lena_ward_segmentation.png"></a>
163+
<a href="{{ pathto('auto_examples/cluster/plot_face_ward_segmentation') }}">
164+
<img src="_images/plot_face_ward_segmentation.png"></a>
165165
</div>
166166
</div>
167167
<!-- Carousel nav -->

0 commit comments

Comments
 (0)