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

[Lint] Pylint #330

Merged
merged 18 commits into from
Jan 1, 2019
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
4 changes: 1 addition & 3 deletions python/dgl/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# One has to manually import dgl.data; fixes #125
#from . import data
"""DGL root package."""
from . import function
from . import nn
from . import contrib
Expand All @@ -12,7 +11,6 @@
from .backend import load_backend
from .batched_graph import *
from .graph import DGLGraph
from .subgraph import DGLSubGraph
from .traversal import *
from .propagate import *
from .udf import NodeBatch, EdgeBatch
1 change: 1 addition & 0 deletions python/dgl/_api_internal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Namespace for internal apis."""
3 changes: 1 addition & 2 deletions python/dgl/_ffi/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@

class DGLError(Exception):
"""Error thrown by DGL function"""
pass

pass # pylint: disable=unnecessary-pass

def _load_lib():
"""Load libary by searching possible path."""
Expand Down
2 changes: 1 addition & 1 deletion python/dgl/_ffi/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Function(_FunctionBase):
dgl.register_func: How to register global function.
dgl.get_global_func: How to get global function.
"""
pass
pass # pylint: disable=unnecessary-pass


class ModuleBase(object):
Expand Down
2 changes: 1 addition & 1 deletion python/dgl/_ffi/runtime_ctypes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Common runtime ctypes."""
# pylint: disable=invalid-name
# pylint: disable=invalid-name, super-init-not-called
from __future__ import absolute_import

import ctypes
Expand Down
25 changes: 25 additions & 0 deletions python/dgl/backend/mxnet/immutable_graph_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,31 @@ def from_coo_matrix(self, out_coo):
self.__init__(mx.nd.sparse.csr_matrix((edge_ids, (dst, src)), shape=(size, size)).astype(np.int64),
mx.nd.sparse.csr_matrix((edge_ids, (src, dst)), shape=(size, size)).astype(np.int64))

def from_edge_list(self, elist):
"""Convert from an edge list.

Paramters
---------
elist : list
List of (u, v) edge tuple.
"""
src, dst = zip(*elist)
src = np.array(src)
dst = np.array(dst)
num_nodes = max(src.max(), dst.max()) + 1
min_nodes = min(src.min(), dst.min())
if min_nodes != 0:
raise DGLError('Invalid edge list. Nodes must start from 0.')
edge_ids = mx.nd.arange(0, len(src), step=1, repeat=1, dtype=np.int32)
src = mx.nd.array(src, dtype=np.int64)
dst = mx.nd.array(dst, dtype=np.int64)
# TODO we can't generate a csr_matrix with np.int64 directly.
in_csr = mx.nd.sparse.csr_matrix((edge_ids, (dst, src)),
shape=(num_nodes, num_nodes)).astype(np.int64)
out_csr = mx.nd.sparse.csr_matrix((edge_ids, (src, dst)),
shape=(num_nodes, num_nodes)).astype(np.int64)
self.__init__(in_csr, out_csr)

def create_immutable_graph_index(in_csr=None, out_csr=None):
""" Create an empty backend-specific immutable graph index.

Expand Down
9 changes: 6 additions & 3 deletions python/dgl/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@

import warnings

from ._ffi.base import DGLError
from ._ffi.base import DGLError # pylint: disable=unused-import

# A special argument for selecting all nodes/edges.
# A special symbol for selecting all nodes or edges.
ALL = "__ALL__"

def is_all(arg):
"""Return true if the argument is a special symbol for all nodes or edges."""
return isinstance(arg, str) and arg == ALL

dgl_warning = warnings.warn
def dgl_warning(msg):
"""Print out warning messages."""
warnings.warn(msg)
Loading