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
a19d5f3b
Unverified
Commit
a19d5f3b
authored
Dec 05, 2023
by
Ramon Zhou
Committed by
GitHub
Dec 05, 2023
Browse files
[Misc] Fix recursive_apply when data is a tuple (#6684)
parent
9c241d83
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
0 deletions
+7
-0
python/dgl/utils/internal.py
python/dgl/utils/internal.py
+7
-0
No files found.
python/dgl/utils/internal.py
View file @
a19d5f3b
...
@@ -1127,6 +1127,8 @@ def recursive_apply(data, fn, *args, **kwargs):
...
@@ -1127,6 +1127,8 @@ def recursive_apply(data, fn, *args, **kwargs):
return
{
return
{
k
:
recursive_apply
(
v
,
fn
,
*
args
,
**
kwargs
)
for
k
,
v
in
data
.
items
()
k
:
recursive_apply
(
v
,
fn
,
*
args
,
**
kwargs
)
for
k
,
v
in
data
.
items
()
}
}
elif
isinstance
(
data
,
tuple
):
return
tuple
(
recursive_apply
(
v
,
fn
,
*
args
,
**
kwargs
)
for
v
in
data
)
elif
is_listlike
(
data
):
elif
is_listlike
(
data
):
return
[
recursive_apply
(
v
,
fn
,
*
args
,
**
kwargs
)
for
v
in
data
]
return
[
recursive_apply
(
v
,
fn
,
*
args
,
**
kwargs
)
for
v
in
data
]
else
:
else
:
...
@@ -1142,6 +1144,11 @@ def recursive_apply_pair(data1, data2, fn, *args, **kwargs):
...
@@ -1142,6 +1144,11 @@ def recursive_apply_pair(data1, data2, fn, *args, **kwargs):
k
:
recursive_apply_pair
(
data1
[
k
],
data2
[
k
],
fn
,
*
args
,
**
kwargs
)
k
:
recursive_apply_pair
(
data1
[
k
],
data2
[
k
],
fn
,
*
args
,
**
kwargs
)
for
k
in
data1
.
keys
()
for
k
in
data1
.
keys
()
}
}
elif
isinstance
(
data1
,
tuple
)
and
isinstance
(
data2
,
tuple
):
return
tuple
(
recursive_apply_pair
(
x
,
y
,
fn
,
*
args
,
**
kwargs
)
for
x
,
y
in
zip
(
data1
,
data2
)
)
elif
is_listlike
(
data1
)
and
is_listlike
(
data2
):
elif
is_listlike
(
data1
)
and
is_listlike
(
data2
):
return
[
return
[
recursive_apply_pair
(
x
,
y
,
fn
,
*
args
,
**
kwargs
)
recursive_apply_pair
(
x
,
y
,
fn
,
*
args
,
**
kwargs
)
...
...
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