File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change 11
11
cityscapes_root , svhn_root
12
12
13
13
14
+ try :
15
+ import scipy
16
+ HAS_SCIPY = True
17
+ except ImportError :
18
+ HAS_SCIPY = False
19
+
20
+
14
21
class Tester (unittest .TestCase ):
15
22
def generic_classification_dataset_test (self , dataset , num_images = 1 ):
16
23
self .assertEqual (len (dataset ), num_images )
@@ -101,6 +108,7 @@ def test_fashionmnist(self, mock_download_extract):
101
108
self .assertEqual (dataset .class_to_idx [dataset .classes [0 ]], target )
102
109
103
110
@mock .patch ('torchvision.datasets.utils.download_url' )
111
+ @unittest .skipIf (not HAS_SCIPY , "scipy unavailable" )
104
112
def test_imagenet (self , mock_download ):
105
113
with imagenet_root () as root :
106
114
dataset = torchvision .datasets .ImageNet (root , split = 'train' , download = True )
@@ -187,6 +195,7 @@ def test_cityscapes(self):
187
195
self .assertTrue (isinstance (output [1 ][2 ], PIL .Image .Image )) # color
188
196
189
197
@mock .patch ('torchvision.datasets.SVHN._check_integrity' )
198
+ @unittest .skipIf (not HAS_SCIPY , "scipy unavailable" )
190
199
def test_svhn (self , mock_check ):
191
200
mock_check .return_value = True
192
201
with svhn_root () as root :
You can’t perform that action at this time.
0 commit comments