44import os
55import pathlib
66import re
7- import tarfile
87from collections .abc import Iterable
98from io import BytesIO
109from typing import Any , Callable , Iterator , List , Optional , Tuple , Union
@@ -64,12 +63,12 @@ def _fetch_data(self, path: str) -> Any:
6463 def _load_data (data : io .BytesIO , path : str ) -> Any :
6564 if path .endswith (".pt" ):
6665 data = torch .load (data )
67- elif path .endswith (".tar.gz" ) or path .endswith (".tgz" ):
68- tarfile .open (fileobj = data )
66+ elif path .endswith (".tar.gz" ) or path .endswith (".tgz" ): # pragma: no cover
6967 raise NotImplementedError ("Tar loader not implemented!" )
68+ # tarfile.open(fileobj=data)
7069 # tar = tarfile.open(fileobj=data)
7170 # for member in tar.getmembers():
72- else :
71+ else : # pragma: no cover
7372 raise NotImplementedError ()
7473
7574 return data
@@ -86,10 +85,10 @@ def __getitem__(self, index):
8685 def __len__ (self ):
8786 return len (self ._paths )
8887
89- def _data_fn (self , data ) -> Any :
88+ def _data_fn (self , data ) -> Any : # pragma: no cover
9089 raise NotImplementedError ()
9190
92- def _label_fn (self , path : str ) -> Any :
91+ def _label_fn (self , path : str ) -> Any : # pragma: no cover
9392 raise NotImplementedError ()
9493
9594
@@ -100,7 +99,7 @@ def _label_fn(self, path: str) -> torch.Tensor:
10099 label = int (re .findall (r"/(.*?)=(.*?)/" , path )[- 1 ][1 ])
101100 return torch .tensor ([label ]) # pylint: disable=not-callable
102101
103- def _data_fn (self , data ) -> Any :
102+ def _data_fn (self , data ) -> Any : # pragma: no cover
104103 raise NotImplementedError ()
105104
106105
@@ -383,9 +382,8 @@ def __iter__(self) -> Union[Iterator[torch.Tensor], Iterator[Tuple[torch.Tensor,
383382 pass
384383 elif isinstance (data , Iterable ) and all ([isinstance (d , torch .Tensor ) for d in data ]):
385384 data = zip (* data )
386- else :
385+ else : # pragma: no cover
387386 raise NotImplementedError (f"ERROR: Type: { type (data )} has not been implemented!" )
388-
389387 for d in data :
390388 yield d
391389
@@ -436,7 +434,7 @@ def __init__(
436434 def __iter__ (self ) -> Union [Iterator [torch .Tensor ], Iterator [Tuple [torch .Tensor , torch .Tensor ]]]:
437435 """Iterate over the Dataset."""
438436 if torch .utils .data .get_worker_info () is not None : # type: ignore
439- raise NotImplementedError ()
437+ raise NotImplementedError () # pragma: no cover
440438 db ._validate_engine (con = self ._con ) # pylint: disable=protected-access
441439 with self ._con .connect () as con :
442440 cursor : Any = con .execute (self ._sql )
0 commit comments