8000 TST covertype loader · amueller/scikit-learn@81428f7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 81428f7

Browse files
larsmansamueller
authored andcommitted
TST covertype loader
1 parent 16e595a commit 81428f7

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
"""Test the covtype loader.
2+
3+
Skipped if covtype is not already downloaded to data_home.
4+
"""
5+
6+
import errno
7+
from sklearn.datasets import fetch_covtype
8+
from sklearn.utils.testing import assert_equal, SkipTest
9+
10+
11+
def fetch(*args, **kwargs):
12+
return fetch_covtype(*args, download_if_missing=False, **kwargs)
13+
14+
15+
def test_fetch():
16+
try:
17+
data1 = fetch(shuffle=True, random_state=42)
18+
except IOError as e:
19+
if e.errno == errno.ENOENT:
20+
raise SkipTest()
21+
22+
data2 = fetch(shuffle=True, random_state=37)
23+
24+
X1, X2 = data1.data, data2.data
25+
assert_equal((581012, 54), X1.shape)
26+
assert_equal(X1.shape, X2.shape)
27+
28+
assert_equal(X1.sum(), X2.sum())
29+
30+
y1, y2 = data1.target, data2.target
31+
assert_equal((X1.shape[0],), y1.shape)
32+
assert_equal((X1.shape[0],), y2.shape)

0 commit comments

Comments
 (0)
0