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