Skip to content

Commit

Permalink
[Code Coverage] data/view.py (#7093)
Browse files Browse the repository at this point in the history
Created code coverage for `data/view.py`.

---------

Co-authored-by: ThePuzzlr <90777621+ThePuzzlr@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: rusty1s <matthias.fey@tu-dortmund.de>
  • Loading branch information
4 people authored Apr 9, 2023
1 parent 271c113 commit 1af056c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

### Changed

- Improved code coverage ([#7093](https://github.com/pyg-team/pytorch_geometric/pull/7093))
- Fix `numpy` incompatiblity when reading files for `Planetoid` datasets ([#7141](https://github.com/pyg-team/pytorch_geometric/pull/7141))
- Added support for `Data.num_edges` for native `torch.sparse.Tensor` adjacency matrices ([#7104](https://github.com/pyg-team/pytorch_geometric/pull/7104))
- Fixed crash of heterogeneous data loaders if node or edge types are missing ([#7060](https://github.com/pyg-team/pytorch_geometric/pull/7060), [#7087](https://github.com/pyg-team/pytorch_geometric/pull/7087))
Expand Down
31 changes: 31 additions & 0 deletions test/data/test_view.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from torch_geometric.data.storage import BaseStorage


def test_views():
storage = BaseStorage(x=1, y=2, z=3)

assert str(storage.keys()) == "KeysView({'x': 1, 'y': 2, 'z': 3})"
assert len(storage.keys()) == 3
assert list(storage.keys()) == ['x', 'y', 'z']

assert str(storage.values()) == "ValuesView({'x': 1, 'y': 2, 'z': 3})"
assert len(storage.values()) == 3
assert list(storage.values()) == [1, 2, 3]

assert str(storage.items()) == "ItemsView({'x': 1, 'y': 2, 'z': 3})"
assert len(storage.items()) == 3
assert list(storage.items()) == [('x', 1), ('y', 2), ('z', 3)]

args = ['x', 'z', 'foo']

assert str(storage.keys(*args)) == "KeysView({'x': 1, 'z': 3})"
assert len(storage.keys(*args)) == 2
assert list(storage.keys(*args)) == ['x', 'z']

assert str(storage.values(*args)) == "ValuesView({'x': 1, 'z': 3})"
assert len(storage.values(*args)) == 2
assert list(storage.values(*args)) == [1, 3]

assert str(storage.items(*args)) == "ItemsView({'x': 1, 'z': 3})"
assert len(storage.items(*args)) == 2
assert list(storage.items(*args)) == [('x', 1), ('z', 3)]

0 comments on commit 1af056c

Please sign in to comment.