2424
2525from sklearn .datasets import load_lfw_pairs
2626from sklearn .datasets import load_lfw_people
27+ from sklearn .datasets import fetch_lfw_pairs
28+ from sklearn .datasets import fetch_lfw_people
2729
2830from sklearn .utils .testing import assert_array_equal
2931from sklearn .utils .testing import assert_equal
32+ from sklearn .utils .testing import assert_warns_message
3033from sklearn .utils .testing import SkipTest
3134from sklearn .utils .testing import raises
3235
@@ -112,12 +115,20 @@ def teardown_module():
112115
113116@raises (IOError )
114117def test_load_empty_lfw_people ():
115- load_lfw_people (data_home = SCIKIT_LEARN_EMPTY_DATA )
118+ fetch_lfw_people (data_home = SCIKIT_LEARN_EMPTY_DATA , download_if_missing = False )
119+
120+
121+ def test_load_lfw_people_deprecation ():
122+ msg = ("Function 'load_lfw_people' has been deprecated in 0.17 and will be "
123+ "removed in 0.19."
124+ "Use fetch_lfw_people(download_if_missing=False) instead." )
125+ assert_warns_message (DeprecationWarning , msg , load_lfw_people ,
126+ data_home = SCIKIT_LEARN_DATA )
116127
117128
118129def test_load_fake_lfw_people ():
119- lfw_people = load_lfw_people (data_home = SCIKIT_LEARN_DATA ,
120- min_faces_per_person = 3 )
130+ lfw_people = fetch_lfw_people (data_home = SCIKIT_LEARN_DATA ,
131+ min_faces_per_person = 3 , download_if_missing = False )
121132
122133 # The data is croped around the center as a rectangular bounding box
123134 # arounthe the face. Colors are converted to gray levels:
@@ -133,8 +144,8 @@ def test_load_fake_lfw_people():
133144
134145 # It is possible to ask for the original data without any croping or color
135146 # conversion and not limit on the number of picture per person
136- lfw_people = load_lfw_people (data_home = SCIKIT_LEARN_DATA ,
137- resize = None , slice_ = None , color = True )
147+ lfw_people = fetch_lfw_people (data_home = SCIKIT_LEARN_DATA ,
148+ resize = None , slice_ = None , color = True , download_if_missing = False )
138149 assert_equal (lfw_people .images .shape , (17 , 250 , 250 , 3 ))
139150
140151 # the ids and class names are the same as previously
@@ -147,16 +158,24 @@ def test_load_fake_lfw_people():
147158
148159@raises (ValueError )
149160def test_load_fake_lfw_people_too_restrictive ():
150- load_lfw_people (data_home = SCIKIT_LEARN_DATA , min_faces_per_person = 100 )
161+ fetch_lfw_people (data_home = SCIKIT_LEARN_DATA , min_faces_per_person = 100 , download_if_missing = False )
151162
152163
153164@raises (IOError )
154165def test_load_empty_lfw_pairs ():
155- load_lfw_pairs (data_home = SCIKIT_LEARN_EMPTY_DATA )
166+ fetch_lfw_pairs (data_home = SCIKIT_LEARN_EMPTY_DATA , download_if_missing = False )
167+
168+
169+ def test_load_lfw_pairs_deprecation ():
170+ msg = ("Function 'load_lfw_pairs' has been deprecated in 0.17 and will be "
171+ "removed in 0.19."
172+ "Use fetch_lfw_pairs(download_if_missing=False) instead." )
173+ assert_warns_message (DeprecationWarning , msg , load_lfw_pairs ,
174+ data_home = SCIKIT_LEARN_DATA )
156175
157176
158177def test_load_fake_lfw_pairs ():
159- lfw_pairs_train = load_lfw_pairs (data_home = SCIKIT_LEARN_DATA )
178+ lfw_pairs_train = fetch_lfw_pairs (data_home = SCIKIT_LEARN_DATA , download_if_missing = False )
160179
161180 # The data is croped around the center as a rectangular bounding box
162181 # arounthe the face. Colors are converted to gray levels:
@@ -171,8 +190,8 @@ def test_load_fake_lfw_pairs():
171190
172191 # It is possible to ask for the original data without any croping or color
173192 # conversion
174- lfw_pairs_train = load_lfw_pairs (data_home = SCIKIT_LEARN_DATA ,
175- resize = None , slice_ = None , color = True )
193+ lfw_pairs_train = fetch_lfw_pairs (data_home = SCIKIT_LEARN_DATA ,
194+ resize = None , slice_ = None , color = True , download_if_missing = False )
176195 assert_equal (lfw_pairs_train .pairs .shape , (10 , 2 , 250 , 250 , 3 ))
177196
178197 # the ids and class names are the same as previously
0 commit comments