Skip to content

Commit

Permalink
Cleaned-up imports in test files related to datasets (pytorch#3720)
Browse files Browse the repository at this point in the history
  • Loading branch information
prabhat00155 authored Apr 26, 2021
1 parent eda9435 commit 5bc68cc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 37 deletions.
2 changes: 0 additions & 2 deletions test/datasets_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import collections.abc
import contextlib
import functools
import importlib
Expand All @@ -15,7 +14,6 @@

import PIL
import PIL.Image

import torch
import torchvision.datasets
import torchvision.io
Expand Down
16 changes: 7 additions & 9 deletions test/fakedata_generation.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
import os
import contextlib
import hashlib
import pickle
import re
import tarfile
import json
import unittest.mock
from distutils import dir_util

import numpy as np
import PIL
import torch

from common_utils import get_tmp_dir
import pickle
import random
from itertools import cycle
from torchvision.io.video import write_video
import unittest.mock
import hashlib
from distutils import dir_util
import re


def mock_class_attribute(stack, target, new):
Expand Down
39 changes: 13 additions & 26 deletions test/test_datasets.py
Original file line number Diff line number Diff line change
@@ -1,44 +1,31 @@
import bz2
import contextlib
import sys
import os
import unittest
import numpy as np
import PIL
from PIL import Image
from torch._utils_internal import get_file_path_2
import torchvision
from torchvision.datasets import utils
from common_utils import get_tmp_dir
import xml.etree.ElementTree as ET
from urllib.request import Request, urlopen
import io
import itertools
import datasets_utils
import os
import pathlib
import pickle
from torchvision import datasets
import torch
import shutil
import json
import random
import bz2
import torch.nn.functional as F
import shutil
import string
import io
import unittest
import xml.etree.ElementTree as ET
import zipfile

import PIL
import datasets_utils
import numpy as np
import torch
import torch.nn.functional as F
from torchvision import datasets

try:
import scipy
HAS_SCIPY = True
except ImportError:
HAS_SCIPY = False

try:
import av
HAS_PYAV = True
except ImportError:
HAS_PYAV = False


class STL10TestCase(datasets_utils.ImageDatasetTestCase):
DATASET_CLASS = datasets.STL10
Expand Down Expand Up @@ -946,7 +933,7 @@ def _create_lmdb(self, root, cls):
key = "".join(random.choice(hexdigits_lowercase) for _ in range(40)).encode()

buffer = io.BytesIO()
Image.open(file).save(buffer, format)
PIL.Image.open(file).save(buffer, format)
buffer.seek(0)
value = buffer.read()

Expand Down

0 comments on commit 5bc68cc

Please sign in to comment.