File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 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 )
You can’t perform that action at this time.
0 commit comments