Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up warnings #4429

Merged
merged 2 commits into from
Apr 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ test=pytest

[tool:pytest]
addopts = --capture=no
filterwarnings=ignore::DeprecationWarning:tensorboard.*

[flake8]
ignore=F811,W503,W504 # ignore overload redefinition, allow line breaks before/after binary operators
Expand Down
15 changes: 9 additions & 6 deletions test/data/test_data.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import copy

import pytest
import torch
import torch.multiprocessing as mp

Expand Down Expand Up @@ -80,7 +81,8 @@ def test_data():

assert data.num_nodes == 3
assert data.num_edges == 4
assert data.num_faces is None
with pytest.warns(UserWarning, match='deprecated'):
assert data.num_faces is None
assert data.num_node_features == 2
assert data.num_features == 2

Expand All @@ -89,10 +91,12 @@ def test_data():
data.edge_attr = None

data.x = None
assert data.num_nodes == 3
with pytest.warns(UserWarning, match='Unable to accurately infer'):
assert data.num_nodes == 3

data.edge_index = None
assert data.num_nodes is None
with pytest.warns(UserWarning, match='Unable to accurately infer'):
assert data.num_nodes is None
assert data.num_edges == 0

data.num_nodes = 4
Expand All @@ -105,7 +109,8 @@ def test_data():

face = torch.tensor([[0, 1], [1, 2], [2, 3]])
data = Data(num_nodes=4, face=face)
assert data.num_faces == 2
with pytest.warns(UserWarning, match='deprecated'):
assert data.num_faces == 2
assert data.num_nodes == 4

data = Data(title='test')
Expand Down Expand Up @@ -181,11 +186,9 @@ def test_debug_data():
torch_geometric.set_debug(True)

Data()
Data(edge_index=torch.tensor([[0, 1], [1, 0]])).num_nodes
Data(edge_index=torch.zeros((2, 0), dtype=torch.long), num_nodes=10)
Data(face=torch.zeros((3, 0), dtype=torch.long), num_nodes=10)
Data(edge_index=torch.tensor([[0, 1], [1, 0]]), edge_attr=torch.randn(2))
Data(face=torch.tensor([[0], [1], [2]])).num_nodes
Data(x=torch.torch.randn(5, 3), num_nodes=5)
Data(pos=torch.torch.randn(5, 3), num_nodes=5)
Data(norm=torch.torch.randn(5, 3), num_nodes=5)
Expand Down
6 changes: 6 additions & 0 deletions test/nn/conv/test_spline_conv.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import warnings

import torch
from torch_sparse import SparseTensor

Expand All @@ -7,6 +9,8 @@

@withPackage('torch_spline_conv')
def test_spline_conv():
warnings.filterwarnings('ignore', '.*non-optimized CPU version.*')

x1 = torch.randn(4, 8)
x2 = torch.randn(2, 16)
edge_index = torch.tensor([[0, 1, 2, 3], [0, 0, 1, 1]])
Expand Down Expand Up @@ -59,6 +63,8 @@ def test_spline_conv():

@withPackage('torch_spline_conv')
def test_lazy_spline_conv():
warnings.filterwarnings('ignore', '.*non-optimized CPU version.*')

x1 = torch.randn(4, 8)
x2 = torch.randn(2, 16)
edge_index = torch.tensor([[0, 1, 2, 3], [0, 0, 1, 1]])
Expand Down
5 changes: 4 additions & 1 deletion test/utils/test_train_test_split_edges.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import pytest
import torch

from torch_geometric.data import Data
Expand All @@ -10,7 +11,9 @@ def test_train_test_split_edges():
edge_attr = torch.arange(edge_index.size(1))
data = Data(edge_index=edge_index, edge_attr=edge_attr)
data.num_nodes = edge_index.max().item() + 1
data = train_test_split_edges(data, val_ratio=0.2, test_ratio=0.3)

with pytest.warns(UserWarning, match='deprecated'):
data = train_test_split_edges(data, val_ratio=0.2, test_ratio=0.3)

assert len(data) == 10
assert data.val_pos_edge_index.size() == (2, 2)
Expand Down
3 changes: 3 additions & 0 deletions torch_geometric/utils/random.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import warnings

import numpy as np
import torch

Expand All @@ -20,6 +22,7 @@ def erdos_renyi_graph(num_nodes, edge_prob, directed=False):
idx = idx + torch.arange(1, num_nodes).view(-1, 1)
idx = idx.view(-1)
else:
warnings.filterwarnings('ignore', '.*pass the indexing argument.*')
idx = torch.combinations(torch.arange(num_nodes), r=2)

# Filter edges.
Expand Down