Skip to content

Commit

Permalink
heterodata collect fix (#3897)
Browse files Browse the repository at this point in the history
  • Loading branch information
rusty1s committed Jan 20, 2022
1 parent 3108d10 commit 052ce24
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions torch_geometric/data/hetero_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,12 @@ def __getattr__(self, key: str) -> Any:
# `data.*` => Link to the `_global_store`.
# Using `data.*_dict` is the same as using `collect()` for collecting
# nodes and edges features.
if bool(re.search('_dict$', key)):
out = self.collect(key[:-5])
if len(out) > 0:
return out
return getattr(self._global_store, key)
if hasattr(self._global_store, key):
return getattr(self._global_store, key)
elif bool(re.search('_dict$', key)):
return self.collect(key[:-5])
raise AttributeError(f"'{self.__class__.__name__}' has no "
f"attribute '{key}'")

def __setattr__(self, key: str, value: Any):
# NOTE: We aim to prevent duplicates in node or edge types.
Expand Down

0 comments on commit 052ce24

Please sign in to comment.