-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Code Coverage]
loader/utils.py
(#7857)
Part of #6528. --------- Co-authored-by: rusty1s <matthias.fey@tu-dortmund.de>
- Loading branch information
1 parent
b965d76
commit e95cdaf
Showing
2 changed files
with
39 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import pytest | ||
import torch | ||
|
||
from torch_geometric.loader.utils import index_select | ||
|
||
|
||
def test_index_select(): | ||
x = torch.randn(3, 5) | ||
index = torch.tensor([0, 2]) | ||
assert torch.equal(index_select(x, index), x[index]) | ||
assert torch.equal(index_select(x, index, dim=-1), x[..., index]) | ||
|
||
|
||
def test_index_select_out_of_range(): | ||
with pytest.raises(IndexError, match="out of range"): | ||
index_select(torch.randn(3, 5), torch.tensor([0, 2, 3])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters