Skip to content

Commit 2a4d538

Browse files
committed
added custom return value
1 parent 2b1ca66 commit 2a4d538

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

chytorch/utils/data/_utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,15 @@ class SuppressException(Dataset):
9595
"""
9696
Catch exceptions in wrapped dataset and return None instead
9797
"""
98-
def __init__(self, dataset):
98+
def __init__(self, dataset, *, default=None):
9999
self.dataset = dataset
100+
self.default = default
100101

101102
def __getitem__(self, item):
102103
try:
103104
return self.dataset[item]
104105
except Exception:
105-
pass
106+
return self.default
106107

107108
def __len__(self):
108109
return len(self.dataset)

0 commit comments

Comments
 (0)