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
16861063
Unverified
Commit
16861063
authored
Feb 25, 2021
by
Quan (Andy) Gan
Committed by
GitHub
Feb 25, 2021
Browse files
change __repr__ (#2696)
Co-authored-by:
Minjie Wang
<
wmjlyjemaine@gmail.com
>
parent
704ec685
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
9 deletions
+7
-9
python/dgl/view.py
python/dgl/view.py
+7
-9
No files found.
python/dgl/view.py
View file @
16861063
"""Views of DGLGraph."""
"""Views of DGLGraph."""
from
__future__
import
absolute_import
from
__future__
import
absolute_import
from
collections
import
namedtuple
from
collections
import
namedtuple
,
defaultdict
from
collections.abc
import
MutableMapping
from
collections.abc
import
MutableMapping
from
.base
import
ALL
,
DGLError
from
.base
import
ALL
,
DGLError
...
@@ -109,12 +109,11 @@ class HeteroNodeDataView(MutableMapping):
...
@@ -109,12 +109,11 @@ class HeteroNodeDataView(MutableMapping):
def
__repr__
(
self
):
def
__repr__
(
self
):
if
isinstance
(
self
.
_ntype
,
list
):
if
isinstance
(
self
.
_ntype
,
list
):
ret
=
{}
ret
=
defaultdict
(
dict
)
for
(
i
,
ntype
)
in
enumerate
(
self
.
_ntype
):
for
(
i
,
ntype
)
in
enumerate
(
self
.
_ntype
):
data
=
self
.
_graph
.
_get_n_repr
(
self
.
_ntid
[
i
],
self
.
_nodes
)
data
=
self
.
_graph
.
_get_n_repr
(
self
.
_ntid
[
i
],
self
.
_nodes
)
value
=
{
key
:
data
[
key
]
for
key
in
self
.
_graph
.
_node_frames
[
self
.
_ntid
[
i
]]:
for
key
in
self
.
_graph
.
_node_frames
[
self
.
_ntid
[
i
]]}
ret
[
key
][
ntype
]
=
data
[
key
]
ret
[
ntype
]
=
value
return
repr
(
ret
)
return
repr
(
ret
)
else
:
else
:
data
=
self
.
_graph
.
_get_n_repr
(
self
.
_ntid
,
self
.
_nodes
)
data
=
self
.
_graph
.
_get_n_repr
(
self
.
_ntid
,
self
.
_nodes
)
...
@@ -225,12 +224,11 @@ class HeteroEdgeDataView(MutableMapping):
...
@@ -225,12 +224,11 @@ class HeteroEdgeDataView(MutableMapping):
def
__repr__
(
self
):
def
__repr__
(
self
):
if
isinstance
(
self
.
_etype
,
list
):
if
isinstance
(
self
.
_etype
,
list
):
ret
=
{}
ret
=
defaultdict
(
dict
)
for
(
i
,
etype
)
in
enumerate
(
self
.
_etype
):
for
(
i
,
etype
)
in
enumerate
(
self
.
_etype
):
data
=
self
.
_graph
.
_get_e_repr
(
self
.
_etid
[
i
],
self
.
_edges
)
data
=
self
.
_graph
.
_get_e_repr
(
self
.
_etid
[
i
],
self
.
_edges
)
value
=
{
key
:
data
[
key
]
for
key
in
self
.
_graph
.
_edge_frames
[
self
.
_etid
[
i
]]:
for
key
in
self
.
_graph
.
_edge_frames
[
self
.
_etid
[
i
]]}
ret
[
key
][
etype
]
=
data
[
key
]
ret
[
etype
]
=
value
return
repr
(
ret
)
return
repr
(
ret
)
else
:
else
:
data
=
self
.
_graph
.
_get_e_repr
(
self
.
_etid
,
self
.
_edges
)
data
=
self
.
_graph
.
_get_e_repr
(
self
.
_etid
,
self
.
_edges
)
...
...
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