Skip to content

Commit 754f3d3

Browse files
kmikeapaszke
authored andcommitted
fixed a typo in ConcatDataset.cumulative_sizes attribute name
1 parent 92883f3 commit 754f3d3

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

torch/utils/data/dataset.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import bisect
2+
import warnings
23

34

45
class Dataset(object):
@@ -66,15 +67,21 @@ def __init__(self, datasets):
6667
super(ConcatDataset, self).__init__()
6768
assert len(datasets) > 0, 'datasets should not be an empty iterable'
6869
self.datasets = list(datasets)
69-
self.cummulative_sizes = self.cumsum(self.datasets)
70+
self.cumulative_sizes = self.cumsum(self.datasets)
7071

7172
def __len__(self):
72-
return self.cummulative_sizes[-1]
73+
return self.cumulative_sizes[-1]
7374

7475
def __getitem__(self, idx):
75-
dataset_idx = bisect.bisect_right(self.cummulative_sizes, idx)
76+
dataset_idx = bisect.bisect_right(self.cumulative_sizes, idx)
7677
if dataset_idx == 0:
7778
sample_idx = idx
7879
else:
79-
sample_idx = idx - self.cummulative_sizes[dataset_idx - 1]
80+
sample_idx = idx - self.cumulative_sizes[dataset_idx - 1]
8081
return self.datasets[dataset_idx][sample_idx]
82+
83+
@property
84+
def cummulative_sizes(self):
85+
warnings.warn("cummulative_sizes attribute is renamed to "
86+
"cumulative_sizes", DeprecationWarning, stacklevel=2)
87+
return self.cumulative_sizes

0 commit comments

Comments
 (0)