Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
vision
Commits
6c7189fc
Unverified
Commit
6c7189fc
authored
Aug 06, 2019
by
Francisco Massa
Committed by
GitHub
Aug 06, 2019
Browse files
Skip tests that require scipy if not available (#1201)
parent
7253e816
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
0 deletions
+9
-0
test/test_datasets.py
test/test_datasets.py
+9
-0
No files found.
test/test_datasets.py
View file @
6c7189fc
...
...
@@ -11,6 +11,13 @@ from fakedata_generation import mnist_root, cifar_root, imagenet_root, \
cityscapes_root
,
svhn_root
try
:
import
scipy
HAS_SCIPY
=
True
except
ImportError
:
HAS_SCIPY
=
False
class
Tester
(
unittest
.
TestCase
):
def
generic_classification_dataset_test
(
self
,
dataset
,
num_images
=
1
):
self
.
assertEqual
(
len
(
dataset
),
num_images
)
...
...
@@ -101,6 +108,7 @@ class Tester(unittest.TestCase):
self
.
assertEqual
(
dataset
.
class_to_idx
[
dataset
.
classes
[
0
]],
target
)
@
mock
.
patch
(
'torchvision.datasets.utils.download_url'
)
@
unittest
.
skipIf
(
not
HAS_SCIPY
,
"scipy unavailable"
)
def
test_imagenet
(
self
,
mock_download
):
with
imagenet_root
()
as
root
:
dataset
=
torchvision
.
datasets
.
ImageNet
(
root
,
split
=
'train'
,
download
=
True
)
...
...
@@ -187,6 +195,7 @@ class Tester(unittest.TestCase):
self
.
assertTrue
(
isinstance
(
output
[
1
][
2
],
PIL
.
Image
.
Image
))
# color
@
mock
.
patch
(
'torchvision.datasets.SVHN._check_integrity'
)
@
unittest
.
skipIf
(
not
HAS_SCIPY
,
"scipy unavailable"
)
def
test_svhn
(
self
,
mock_check
):
mock_check
.
return_value
=
True
with
svhn_root
()
as
root
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment