Unverified Commit 37bd0925 authored by Mufei Li's avatar Mufei Li Committed by GitHub
Browse files

[Sparse] Namespace migration and doc update (#5088)



* update

* lint

* lint

* comments
Co-authored-by: default avatarUbuntu <ubuntu@ip-172-31-36-188.ap-northeast-1.compute.internal>
parent e65fc9ff
"""DGL unary operators for diagonal matrix module.""" """DGL unary operators for diagonal matrix module."""
# pylint: disable= invalid-name # pylint: disable= invalid-name
from .diag_matrix import DiagMatrix, diag from .diag_matrix import diag, DiagMatrix
def neg(D: DiagMatrix) -> DiagMatrix: def neg(D: DiagMatrix) -> DiagMatrix:
......
""" DGL mock_sparse2 tests"""
\ No newline at end of file
""" DGL sparse tests"""
...@@ -4,7 +4,7 @@ import backend as F ...@@ -4,7 +4,7 @@ import backend as F
import pytest import pytest
import torch import torch
from dgl.mock_sparse2 import diag, DiagMatrix, identity from dgl.sparse import diag, DiagMatrix, identity
# TODO(#4818): Skipping tests on win. # TODO(#4818): Skipping tests on win.
if not sys.platform.startswith("linux"): if not sys.platform.startswith("linux"):
......
...@@ -4,8 +4,13 @@ import backend as F ...@@ -4,8 +4,13 @@ import backend as F
import pytest import pytest
import torch import torch
from dgl.mock_sparse2 import (add, create_from_coo, create_from_csc, from dgl.sparse import (
create_from_csr, diag) add,
create_from_coo,
create_from_csc,
create_from_csr,
diag,
)
# TODO(#4818): Skipping tests on win. # TODO(#4818): Skipping tests on win.
if not sys.platform.startswith("linux"): if not sys.platform.startswith("linux"):
......
...@@ -5,7 +5,7 @@ import backend as F ...@@ -5,7 +5,7 @@ import backend as F
import pytest import pytest
import torch import torch
from dgl.mock_sparse2 import diag, power from dgl.sparse import diag, power
# TODO(#4818): Skipping tests on win. # TODO(#4818): Skipping tests on win.
if not sys.platform.startswith("linux"): if not sys.platform.startswith("linux"):
...@@ -18,9 +18,7 @@ def all_close_sparse(A, B): ...@@ -18,9 +18,7 @@ def all_close_sparse(A, B):
assert A.shape == B.shape assert A.shape == B.shape
@pytest.mark.parametrize( @pytest.mark.parametrize("op", [operator.sub, operator.mul, operator.truediv])
"op", [operator.sub, operator.mul, operator.truediv]
)
def test_diag_op_diag(op): def test_diag_op_diag(op):
ctx = F.ctx() ctx = F.ctx()
shape = (3, 4) shape = (3, 4)
......
...@@ -4,7 +4,7 @@ import backend as F ...@@ -4,7 +4,7 @@ import backend as F
import pytest import pytest
import torch import torch
from dgl.mock_sparse2 import create_from_coo, power from dgl.sparse import create_from_coo, power
# TODO(#4818): Skipping tests on win. # TODO(#4818): Skipping tests on win.
if not sys.platform.startswith("linux"): if not sys.platform.startswith("linux"):
......
import os import os
import subprocess import subprocess
import sys import sys
import pytest import pytest
# TODO(#4818): Skipping tests on win. # TODO(#4818): Skipping tests on win.
......
...@@ -4,7 +4,7 @@ import backend as F ...@@ -4,7 +4,7 @@ import backend as F
import pytest import pytest
import torch import torch
from dgl.mock_sparse2 import bspmm, create_from_coo, val_like from dgl.sparse import bspmm, create_from_coo, val_like
from .utils import ( from .utils import (
clone_detach_and_grad, clone_detach_and_grad,
......
...@@ -4,7 +4,7 @@ import sys ...@@ -4,7 +4,7 @@ import sys
import backend as F import backend as F
import dgl.mock_sparse2 as dglsp import dgl.sparse as dglsp
import pytest import pytest
import torch import torch
......
...@@ -3,7 +3,7 @@ import sys ...@@ -3,7 +3,7 @@ import sys
import backend as F import backend as F
import pytest import pytest
import torch import torch
from dgl.mock_sparse2 import bsddmm, sddmm from dgl.sparse import bsddmm, sddmm
from .utils import clone_detach_and_grad, rand_coo, rand_csc, rand_csr from .utils import clone_detach_and_grad, rand_coo, rand_csc, rand_csr
......
...@@ -6,7 +6,7 @@ import dgl ...@@ -6,7 +6,7 @@ import dgl
import pytest import pytest
import torch import torch
from dgl.mock_sparse2 import create_from_coo, softmax from dgl.sparse import create_from_coo, softmax
# TODO(#4818): Skipping tests on win. # TODO(#4818): Skipping tests on win.
if not sys.platform.startswith("linux"): if not sys.platform.startswith("linux"):
......
...@@ -4,7 +4,7 @@ import backend as F ...@@ -4,7 +4,7 @@ import backend as F
import pytest import pytest
import torch import torch
from dgl.mock_sparse2 import ( from dgl.sparse import (
create_from_coo, create_from_coo,
create_from_csc, create_from_csc,
create_from_csr, create_from_csr,
......
import pytest
import torch
import sys import sys
from dgl.mock_sparse2 import diag, create_from_coo
import backend as F import backend as F
import pytest
import torch
from dgl.sparse import create_from_coo, diag
# TODO(#4818): Skipping tests on win. # TODO(#4818): Skipping tests on win.
if not sys.platform.startswith("linux"): if not sys.platform.startswith("linux"):
pytest.skip("skipping tests on win", allow_module_level=True) pytest.skip("skipping tests on win", allow_module_level=True)
@pytest.mark.parametrize("val_shape", [(3,), (3, 2)]) @pytest.mark.parametrize("val_shape", [(3,), (3, 2)])
@pytest.mark.parametrize("mat_shape", [None, (3, 5), (5, 3)]) @pytest.mark.parametrize("mat_shape", [None, (3, 5), (5, 3)])
def test_diag_matrix_transpose(val_shape, mat_shape): def test_diag_matrix_transpose(val_shape, mat_shape):
...@@ -43,4 +44,4 @@ def test_sparse_matrix_transpose(dense_dim, row, col, extra_shape): ...@@ -43,4 +44,4 @@ def test_sparse_matrix_transpose(dense_dim, row, col, extra_shape):
assert mat.shape == mat_shape[::-1] assert mat.shape == mat_shape[::-1]
assert torch.allclose(mat_val, val) assert torch.allclose(mat_val, val)
assert torch.allclose(mat_row, col) assert torch.allclose(mat_row, col)
assert torch.allclose(mat_col, row) assert torch.allclose(mat_col, row)
\ No newline at end of file
import pytest
import torch
import sys import sys
import backend as F import backend as F
import pytest
import torch
from dgl.mock_sparse2 import diag from dgl.sparse import diag
def test_neg(): def test_neg():
......
import pytest
import torch
import sys import sys
import backend as F import backend as F
import pytest
import torch
from dgl.mock_sparse2 import create_from_coo from dgl.sparse import create_from_coo
# TODO(#4818): Skipping tests on win. # TODO(#4818): Skipping tests on win.
if not sys.platform.startswith("linux"): if not sys.platform.startswith("linux"):
......
import numpy as np import numpy as np
import torch import torch
from dgl.mock_sparse2 import ( from dgl.sparse import (
create_from_coo, create_from_coo,
create_from_csc, create_from_csc,
create_from_csr, create_from_csr,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment