forked from pyg-team/pytorch_geometric
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
6 changed files
with
88 additions
and
6 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,8 @@ | ||
OFF | ||
4 2 0 | ||
0.0 0.0 0.0 | ||
0.0 1.0 0.0 | ||
1.0 0.0 0.0 | ||
1.0 1.0 0.0 | ||
3 0 1 2 | ||
3 1 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
OFF | ||
4 1 0 | ||
0.0 0.0 0.0 | ||
0.0 1.0 0.0 | ||
1.0 0.0 0.0 | ||
1.0 1.0 0.0 | ||
4 0 1 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import os | ||
import os.path as osp | ||
|
||
import torch | ||
from torch_geometric.data import Data | ||
from torch_geometric.io import read_off, write_off | ||
|
||
|
||
def test_read_off(): | ||
data = read_off(osp.join('test', 'io', 'example1.off')) | ||
assert len(data) == 2 | ||
assert data.pos.tolist() == [[0, 0, 0], [0, 1, 0], [1, 0, 0], [1, 1, 0]] | ||
assert data.face.tolist() == [[0, 1], [1, 2], [2, 3]] | ||
|
||
data = read_off(osp.join('test', 'io', 'example2.off')) | ||
assert len(data) == 2 | ||
assert data.pos.tolist() == [[0, 0, 0], [0, 1, 0], [1, 0, 0], [1, 1, 0]] | ||
assert data.face.tolist() == [[0, 1], [1, 2], [2, 3]] | ||
|
||
|
||
def test_write_off(): | ||
pos = torch.tensor([[0, 0, 0], [0, 1, 0], [1, 0, 0], [1, 1, 0]]) | ||
face = torch.tensor([[0, 1], [1, 2], [2, 3]]) | ||
|
||
path = osp.join('test', 'io', 'example.off') | ||
write_off(Data(pos=pos, face=face), path) | ||
data = read_off(path) | ||
os.unlink(path) | ||
|
||
assert data.pos.tolist() == pos.tolist() | ||
assert data.face.tolist() == face.tolist() |
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