Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dgl
Commits
71c7ee0e
Unverified
Commit
71c7ee0e
authored
Jul 31, 2020
by
Quan (Andy) Gan
Committed by
GitHub
Jul 31, 2020
Browse files
[Bugfix] add DGLWarning class (#1898)
* add DGLWarning class * docstrings * lint
parent
b9ae536e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
3 deletions
+15
-3
python/dgl/base.py
python/dgl/base.py
+15
-3
No files found.
python/dgl/base.py
View file @
71c7ee0e
...
@@ -26,12 +26,24 @@ def is_all(arg):
...
@@ -26,12 +26,24 @@ def is_all(arg):
"""Return true if the argument is a special symbol for all nodes or edges."""
"""Return true if the argument is a special symbol for all nodes or edges."""
return
isinstance
(
arg
,
str
)
and
arg
==
ALL
return
isinstance
(
arg
,
str
)
and
arg
==
ALL
# pylint: disable=invalid-name
_default_formatwarning
=
warnings
.
formatwarning
class
DGLWarning
(
UserWarning
):
"""DGL Warning class."""
# pylint: disable=unused-argument
# pylint: disable=unused-argument
def
dgl_warning_format
(
message
,
category
,
filename
,
lineno
,
file
=
None
,
line
=
None
):
def
dgl_warning_format
(
message
,
category
,
filename
,
lineno
,
line
=
None
):
"""Format DGL warnings."""
"""Format DGL warnings."""
return
"DGL Warning: {}
\n
"
.
format
(
message
)
if
isinstance
(
category
,
DGLWarning
):
return
"DGL Warning: {}
\n
"
.
format
(
message
)
else
:
return
_default_formatwarning
(
message
,
category
,
filename
,
lineno
,
line
=
None
)
def
dgl_warning
(
message
,
category
=
DGLWarning
,
stacklevel
=
1
):
"""DGL warning wrapper that defaults to ``DGLWarning`` instead of ``UserWarning`` category."""
return
warnings
.
warn
(
message
,
category
=
category
,
stacklevel
=
1
)
warnings
.
formatwarning
=
dgl_warning_format
warnings
.
formatwarning
=
dgl_warning_format
dgl_warning
=
warnings
.
warn
# pylint: disable=invalid-name
_init_internal_api
()
_init_internal_api
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment