24
24
25
25
from sklearn .datasets import load_lfw_pairs
26
26
from sklearn .datasets import load_lfw_people
27
+ from sklearn .datasets import fetch_lfw_pairs
28
+ from sklearn .datasets import fetch_lfw_people
27
29
28
30
from sklearn .utils .testing import assert_array_equal
29
31
from sklearn .utils .testing import assert_equal
32
+ from sklearn .utils .testing import assert_warns_message
30
33
from sklearn .utils .testing import SkipTest
31
34
from sklearn .utils .testing import raises
32
35
@@ -112,12 +115,20 @@ def teardown_module():
112
115
113
116
@raises (IOError )
114
117
def 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 )
116
127
117
128
118
129
def 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 )
121
132
122
133
# The data is croped around the center as a rectangular bounding box
123
134
# arounthe the face. Colors are converted to gray levels:
@@ -133,8 +144,8 @@ def test_load_fake_lfw_people():
133
144
134
145
# It is possible to ask for the original data without any croping or color
135
146
# 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 )
138
149
assert_equal (lfw_people .images .shape , (17 , 250 , 250 , 3 ))
139
150
140
151
# the ids and class names are the same as previously
@@ -147,16 +158,24 @@ def test_load_fake_lfw_people():
147
158
148
159
@raises (ValueError )
149
160
def 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 )
151
162
152
163
153
164
@raises (IOError )
154
165
def 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 )
156
175
157
176
158
177
def 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 )
160
179
161
180
# The data is croped around the center as a rectangular bounding box
162
181
# arounthe the face. Colors are converted to gray levels:
@@ -171,8 +190,8 @@ def test_load_fake_lfw_pairs():
171
190
172
191
# It is possible to ask for the original data without any croping or color
173
192
# 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 )
176
195
assert_equal (lfw_pairs_train .pairs .shape , (10 , 2 , 250 , 250 , 3 ))
177
196
178
197
# the ids and class names are the same as previously
0 commit comments