Skip to content

Commit bcdb323

Browse files
committed
fix pre_transform in InMemoryDataset
1 parent 26335c3 commit bcdb323

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

torch_geometric/data/in_memory_dataset.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,13 @@ def len(self):
6767
return 0
6868

6969
def get(self, idx):
70-
if self.__data_list__ is None:
71-
self.__data_list__ = self.len() * [None]
72-
else:
73-
data = self.__data_list__[idx]
74-
if data is not None:
75-
return copy.copy(data)
70+
if hasattr(self, '__data_list__'):
71+
if self.__data_list__ is None:
72+
self.__data_list__ = self.len() * [None]
73+
else:
74+
data = self.__data_list__[idx]
75+
if data is not None:
76+
return copy.copy(data)
7677

7778
data = self.data.__class__()
7879
if hasattr(self.data, '__num_nodes__'):
@@ -90,7 +91,9 @@ def get(self, idx):
9091
s = slice(start, end)
9192
data[key] = item[s]
9293

93-
self.__data_list__[idx] = copy.copy(data)
94+
if hasattr(self, '__data_list__'):
95+
self.__data_list__[idx] = copy.copy(data)
96+
9497
return data
9598

9699
@staticmethod

0 commit comments

Comments
 (0)