Skip to content

Commit 6387051

Browse files
authored
Simplify _check_integrity for cifar and stl10 (#6335)
1 parent 1a1d509 commit 6387051

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

torchvision/datasets/cifar.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,8 @@ def __len__(self) -> int:
126126
return len(self.data)
127127

128128
def _check_integrity(self) -> bool:
129-
root = self.root
130-
for fentry in self.train_list + self.test_list:
131-
filename, md5 = fentry[0], fentry[1]
132-
fpath = os.path.join(root, self.base_folder, filename)
129+
for filename, md5 in self.train_list + self.test_list:
130+
fpath = os.path.join(self.root, self.base_folder, filename)
133131
if not check_integrity(fpath, md5):
134132
return False
135133
return True

torchvision/datasets/stl10.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,8 @@ def __loadfile(self, data_file: str, labels_file: Optional[str] = None) -> Tuple
145145
return images, labels
146146

147147
def _check_integrity(self) -> bool:
148-
root = self.root
149-
for fentry in self.train_list + self.test_list:
150-
filename, md5 = fentry[0], fentry[1]
151-
fpath = os.path.join(root, self.base_folder, filename)
148+
for filename, md5 in self.train_list + self.test_list:
149+
fpath = os.path.join(self.root, self.base_folder, filename)
152150
if not check_integrity(fpath, md5):
153151
return False
154152
return True

0 commit comments

Comments
 (0)