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
f9c4fdf9
Unverified
Commit
f9c4fdf9
authored
Oct 12, 2020
by
Philip Meier
Committed by
GitHub
Oct 12, 2020
Browse files
use more precise return type for gzip.open() (#2792)
parent
831c0df3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
torchvision/datasets/mnist.py
torchvision/datasets/mnist.py
+3
-3
No files found.
torchvision/datasets/mnist.py
View file @
f9c4fdf9
...
...
@@ -7,6 +7,8 @@ import numpy as np
import
torch
import
codecs
import
string
import
gzip
import
lzma
from
typing
import
Any
,
Callable
,
Dict
,
IO
,
List
,
Optional
,
Tuple
,
Union
from
.utils
import
download_url
,
download_and_extract_archive
,
extract_archive
,
\
verify_str_arg
...
...
@@ -435,17 +437,15 @@ def get_int(b: bytes) -> int:
return
int
(
codecs
.
encode
(
b
,
'hex'
),
16
)
def
open_maybe_compressed_file
(
path
:
Union
[
str
,
IO
])
->
IO
:
def
open_maybe_compressed_file
(
path
:
Union
[
str
,
IO
])
->
Union
[
IO
,
gzip
.
GzipFile
]
:
"""Return a file object that possibly decompresses 'path' on the fly.
Decompression occurs when argument `path` is a string and ends with '.gz' or '.xz'.
"""
if
not
isinstance
(
path
,
torch
.
_six
.
string_classes
):
return
path
if
path
.
endswith
(
'.gz'
):
import
gzip
return
gzip
.
open
(
path
,
'rb'
)
if
path
.
endswith
(
'.xz'
):
import
lzma
return
lzma
.
open
(
path
,
'rb'
)
return
open
(
path
,
'rb'
)
...
...
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