Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Restoring the TensorAttr.fully_specify method. #10012

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion torch_geometric/data/feature_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ def is_fully_specified(self) -> bool:
r"""Whether the :obj:`TensorAttr` has no unset fields."""
return all([self.is_set(key) for key in self.__dataclass_fields__])

def fully_specify(self) -> 'TensorAttr':
r"""Sets all :obj:`UNSET` fields to :obj:`None`."""
for key in self.__dataclass_fields__:
if not self.is_set(key):
setattr(self, key, None)
return self

def update(self, attr: 'TensorAttr') -> 'TensorAttr':
r"""Updates an :class:`TensorAttr` with set attributes from another
:class:`TensorAttr`.
Expand Down Expand Up @@ -473,7 +480,9 @@ def __setitem__(self, key: TensorAttr, value: FeatureTensorType):
# CastMixin will handle the case of key being a tuple or TensorAttr
# object:
key = self._tensor_attr_cls.cast(key)
assert key.is_fully_specified()
# We need to fully-specify the key for __setitem__ as it does not make
# sense to work with a view here:
key.fully_specify()
self.put_tensor(value, key)

def __getitem__(self, key: TensorAttr) -> Any:
Expand Down
Loading