Skip to content

Commit

Permalink
changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
rusty1s committed May 19, 2022
1 parent d1a04db commit 3321a2e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Added support for graph-level outputs in `to_hetero` ([#4582](https://github.com/pyg-team/pytorch_geometric/pull/4582))
- Added `CHANGELOG.md` ([#4581](https://github.com/pyg-team/pytorch_geometric/pull/4581))
### Changed
- Allow for `setter` properties in `Data` and `HeteroData` ([#4682](https://github.com/pyg-team/pytorch_geometric/pull/4682))
- Allow for optional `edge_weight` in `GCN2Conv` ([#4670](https://github.com/pyg-team/pytorch_geometric/pull/4670))
- Fixed the interplay between `TUDataset` and `pre_transform` that modify node features ([#4669](https://github.com/pyg-team/pytorch_geometric/pull/4669))
- Make use of the `pyg_sphinx_theme` documentation template ([#4664](https://github.com/pyg-team/pyg-lib/pull/4664), [#4667](https://github.com/pyg-team/pyg-lib/pull/4667))
Expand Down
35 changes: 15 additions & 20 deletions test/data/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,32 +215,27 @@ def test_data_share_memory():
assert torch.allclose(data.x, torch.full((8, ), 4.))


def test_data_subclass_setter():
class Graph(Data):
def test_data_setter_properties():
class MyData(Data):
def __init__(self):
super().__init__()
self.my_attr = 1.0
self.my_attr1 = 1
self.my_attr2 = 2

@property
def my_attr(self):
return self._my_attr
def my_attr1(self):
return self._my_attr1

@my_attr.setter
def my_attr(self, value):
self._my_attr = int(value)
@my_attr1.setter
def my_attr1(self, value):
self._my_attr1 = value

g = Graph()
assert g._store == {'my_attr2': 2}
assert '_my_attr' in g._store.__dict__
assert isinstance(g.my_attr, int)
data = MyData()
assert data.my_attr2 == 2

x = torch.tensor([[1, 2], [3, 4]])
g.x = x
assert g._store == {'x': x, 'my_attr2': 2}
assert 'my_attr1' not in data._store
assert data.my_attr1 == 1

g.my_attr = 2.0
assert isinstance(g.my_attr, int)

g.my_attr2 = 'asdf'
assert g._store == {'x': x, 'my_attr2': 'asdf'}
data.my_attr1 = 2
assert 'my_attr1' not in data._store
assert data.my_attr1 == 2

0 comments on commit 3321a2e

Please sign in to comment.