15
15
import unittest .mock
16
16
import zipfile
17
17
from collections import defaultdict
18
- from typing import Any , Callable , Dict , Iterator , List , Optional , Sequence , Tuple , Union
18
+ from collections .abc import Iterator , Sequence
19
+ from typing import Any , Callable , Optional , Union
19
20
20
21
import numpy as np
21
22
@@ -63,6 +64,7 @@ class LazyImporter:
63
64
provide modules listed in MODULES as attributes. They are only imported when accessed.
64
65
65
66
"""
67
+
66
68
MODULES = (
67
69
"av" ,
68
70
"lmdb" ,
@@ -280,7 +282,7 @@ def test_baz(self):
280
282
"download_and_extract_archive" ,
281
283
}
282
284
283
- def dataset_args (self , tmpdir : str , config : Dict [str , Any ]) -> Sequence [Any ]:
285
+ def dataset_args (self , tmpdir : str , config : dict [str , Any ]) -> Sequence [Any ]:
284
286
"""Define positional arguments passed to the dataset.
285
287
286
288
.. note::
@@ -299,7 +301,7 @@ def dataset_args(self, tmpdir: str, config: Dict[str, Any]) -> Sequence[Any]:
299
301
"""
300
302
return (tmpdir ,)
301
303
302
- def inject_fake_data (self , tmpdir : str , config : Dict [str , Any ]) -> Union [int , Dict [str , Any ]]:
304
+ def inject_fake_data (self , tmpdir : str , config : dict [str , Any ]) -> Union [int , dict [str , Any ]]:
303
305
"""Inject fake data for dataset into a temporary directory.
304
306
305
307
During the creation of the dataset the download and extract logic is disabled. Thus, the fake data injected
@@ -323,11 +325,11 @@ def inject_fake_data(self, tmpdir: str, config: Dict[str, Any]) -> Union[int, Di
323
325
@contextlib .contextmanager
324
326
def create_dataset (
325
327
self ,
326
- config : Optional [Dict [str , Any ]] = None ,
328
+ config : Optional [dict [str , Any ]] = None ,
327
329
inject_fake_data : bool = True ,
328
330
patch_checks : Optional [bool ] = None ,
329
331
** kwargs : Any ,
330
- ) -> Iterator [Tuple [torchvision .datasets .VisionDataset , Dict [str , Any ]]]:
332
+ ) -> Iterator [tuple [torchvision .datasets .VisionDataset , dict [str , Any ]]]:
331
333
r"""Create the dataset in a temporary directory.
332
334
333
335
The configuration passed to the dataset is populated to contain at least all parameters with default values.
@@ -616,11 +618,11 @@ class ImageDatasetTestCase(DatasetTestCase):
616
618
@contextlib .contextmanager
617
619
def create_dataset (
618
620
self ,
619
- config : Optional [Dict [str , Any ]] = None ,
621
+ config : Optional [dict [str , Any ]] = None ,
620
622
inject_fake_data : bool = True ,
621
623
patch_checks : Optional [bool ] = None ,
622
624
** kwargs : Any ,
623
- ) -> Iterator [Tuple [torchvision .datasets .VisionDataset , Dict [str , Any ]]]:
625
+ ) -> Iterator [tuple [torchvision .datasets .VisionDataset , dict [str , Any ]]]:
624
626
with super ().create_dataset (
625
627
config = config ,
626
628
inject_fake_data = inject_fake_data ,
@@ -799,7 +801,7 @@ def create_image_folder(
799
801
num_examples : int ,
800
802
size : Optional [Union [Sequence [int ], int , Callable [[int ], Union [Sequence [int ], int ]]]] = None ,
801
803
** kwargs : Any ,
802
- ) -> List [pathlib .Path ]:
804
+ ) -> list [pathlib .Path ]:
803
805
"""Create a folder of random images.
804
806
805
807
Args:
@@ -821,7 +823,7 @@ def create_image_folder(
821
823
"""
822
824
if size is None :
823
825
824
- def size (idx : int ) -> Tuple [int , int , int ]:
826
+ def size (idx : int ) -> tuple [int , int , int ]:
825
827
num_channels = 3
826
828
height , width = torch .randint (3 , 11 , size = (2 ,), dtype = torch .int ).tolist ()
827
829
return (num_channels , height , width )
@@ -913,7 +915,7 @@ def create_video_folder(
913
915
size : Optional [Union [Sequence [int ], int , Callable [[int ], Union [Sequence [int ], int ]]]] = None ,
914
916
fps = 25 ,
915
917
** kwargs ,
916
- ) -> List [pathlib .Path ]:
918
+ ) -> list [pathlib .Path ]:
917
919
"""Create a folder of random videos.
918
920
919
921
Args:
0 commit comments