-
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.
- Loading branch information
1 parent
fbb7fda
commit b6b6b7e
Showing
2 changed files
with
24 additions
and
20 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
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,23 @@ | ||
import torch | ||
|
||
from torch_geometric.data import Data | ||
from torch_geometric.transforms import MaskToIndex | ||
|
||
|
||
def test_mask_to_index(): | ||
assert MaskToIndex().__repr__() == 'MaskToIndex(attrs=None)' | ||
|
||
train_mask = torch.tensor([1, 0, 1, 1, 0, 0, 0]).bool() | ||
val_mask = torch.tensor([0, 1, 0, 0, 1, 0, 0]).bool() | ||
test_mask = torch.tensor([0, 0, 0, 0, 0, 1, 1]).bool() | ||
data = Data(train_mask=train_mask, val_mask=val_mask, test_mask=test_mask) | ||
|
||
out = MaskToIndex()(data.clone()) | ||
assert len(out) == 6 | ||
assert hasattr(out, "train_indices") | ||
assert hasattr(out, "val_indices") | ||
assert hasattr(out, "test_indices") | ||
|
||
out = MaskToIndex(attrs="train_mask")(data.clone()) | ||
assert len(out) == 4 | ||
assert out.train_indices.numel() == 3 |