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
0038a29b
Unverified
Commit
0038a29b
authored
Dec 15, 2022
by
Xin Yao
Committed by
GitHub
Dec 15, 2022
Browse files
[Fix core lib warning] Fix numpy dtype (#5027)
parent
354a2110
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
12 additions
and
12 deletions
+12
-12
python/dgl/backend/mxnet/tensor.py
python/dgl/backend/mxnet/tensor.py
+4
-4
python/dgl/data/fakenews.py
python/dgl/data/fakenews.py
+3
-3
python/dgl/data/fraud.py
python/dgl/data/fraud.py
+3
-3
python/dgl/data/minigc.py
python/dgl/data/minigc.py
+1
-1
python/dgl/data/qm9.py
python/dgl/data/qm9.py
+1
-1
No files found.
python/dgl/backend/mxnet/tensor.py
View file @
0038a29b
...
@@ -31,7 +31,7 @@ def data_type_dict():
...
@@ -31,7 +31,7 @@ def data_type_dict():
"int16"
:
np
.
int16
,
"int16"
:
np
.
int16
,
"int32"
:
np
.
int32
,
"int32"
:
np
.
int32
,
"int64"
:
np
.
int64
,
"int64"
:
np
.
int64
,
"bool"
:
np
.
bool
,
"bool"
:
np
.
bool
_
,
}
# mxnet does not support bool
}
# mxnet does not support bool
...
@@ -40,7 +40,7 @@ def cpu():
...
@@ -40,7 +40,7 @@ def cpu():
def
tensor
(
data
,
dtype
=
None
):
def
tensor
(
data
,
dtype
=
None
):
if
dtype
==
np
.
bool
:
if
dtype
==
np
.
bool
_
:
# mxnet doesn't support bool
# mxnet doesn't support bool
dtype
=
np
.
int32
dtype
=
np
.
int32
if
isinstance
(
data
,
nd
.
NDArray
):
if
isinstance
(
data
,
nd
.
NDArray
):
...
@@ -53,7 +53,7 @@ def tensor(data, dtype=None):
...
@@ -53,7 +53,7 @@ def tensor(data, dtype=None):
data
=
[
data
]
data
=
[
data
]
if
dtype
is
None
:
if
dtype
is
None
:
if
isinstance
(
data
,
np
.
ndarray
):
if
isinstance
(
data
,
np
.
ndarray
):
dtype
=
np
.
int32
if
data
.
dtype
==
np
.
bool
else
data
.
dtype
dtype
=
np
.
int32
if
data
.
dtype
==
np
.
bool
_
else
data
.
dtype
elif
len
(
data
)
==
0
:
elif
len
(
data
)
==
0
:
dtype
=
np
.
int64
dtype
=
np
.
int64
else
:
else
:
...
@@ -165,7 +165,7 @@ def to_backend_ctx(dglctx):
...
@@ -165,7 +165,7 @@ def to_backend_ctx(dglctx):
def
astype
(
input
,
ty
):
def
astype
(
input
,
ty
):
if
ty
==
np
.
bool
:
if
ty
==
np
.
bool
_
:
ty
=
np
.
int32
ty
=
np
.
int32
return
input
.
astype
(
ty
)
return
input
.
astype
(
ty
)
...
...
python/dgl/data/fakenews.py
View file @
0038a29b
...
@@ -162,9 +162,9 @@ class FakeNewsDataset(DGLBuiltinDataset):
...
@@ -162,9 +162,9 @@ class FakeNewsDataset(DGLBuiltinDataset):
train_idx
=
np
.
load
(
os
.
path
.
join
(
self
.
raw_path
,
"train_idx.npy"
))
train_idx
=
np
.
load
(
os
.
path
.
join
(
self
.
raw_path
,
"train_idx.npy"
))
val_idx
=
np
.
load
(
os
.
path
.
join
(
self
.
raw_path
,
"val_idx.npy"
))
val_idx
=
np
.
load
(
os
.
path
.
join
(
self
.
raw_path
,
"val_idx.npy"
))
test_idx
=
np
.
load
(
os
.
path
.
join
(
self
.
raw_path
,
"test_idx.npy"
))
test_idx
=
np
.
load
(
os
.
path
.
join
(
self
.
raw_path
,
"test_idx.npy"
))
train_mask
=
np
.
zeros
(
num_graphs
,
dtype
=
np
.
bool
)
train_mask
=
np
.
zeros
(
num_graphs
,
dtype
=
np
.
bool
_
)
val_mask
=
np
.
zeros
(
num_graphs
,
dtype
=
np
.
bool
)
val_mask
=
np
.
zeros
(
num_graphs
,
dtype
=
np
.
bool
_
)
test_mask
=
np
.
zeros
(
num_graphs
,
dtype
=
np
.
bool
)
test_mask
=
np
.
zeros
(
num_graphs
,
dtype
=
np
.
bool
_
)
train_mask
[
train_idx
]
=
True
train_mask
[
train_idx
]
=
True
val_mask
[
val_idx
]
=
True
val_mask
[
val_idx
]
=
True
test_mask
[
test_idx
]
=
True
test_mask
[
test_idx
]
=
True
...
...
python/dgl/data/fraud.py
View file @
0038a29b
...
@@ -227,9 +227,9 @@ class FraudDataset(DGLBuiltinDataset):
...
@@ -227,9 +227,9 @@ class FraudDataset(DGLBuiltinDataset):
int
(
train_size
*
len
(
index
))
:
len
(
index
)
int
(
train_size
*
len
(
index
))
:
len
(
index
)
-
int
(
val_size
*
len
(
index
))
-
int
(
val_size
*
len
(
index
))
]
]
train_mask
=
np
.
zeros
(
N
,
dtype
=
np
.
bool
)
train_mask
=
np
.
zeros
(
N
,
dtype
=
np
.
bool
_
)
val_mask
=
np
.
zeros
(
N
,
dtype
=
np
.
bool
)
val_mask
=
np
.
zeros
(
N
,
dtype
=
np
.
bool
_
)
test_mask
=
np
.
zeros
(
N
,
dtype
=
np
.
bool
)
test_mask
=
np
.
zeros
(
N
,
dtype
=
np
.
bool
_
)
train_mask
[
train_idx
]
=
True
train_mask
[
train_idx
]
=
True
val_mask
[
val_idx
]
=
True
val_mask
[
val_idx
]
=
True
test_mask
[
test_idx
]
=
True
test_mask
[
test_idx
]
=
True
...
...
python/dgl/data/minigc.py
View file @
0038a29b
...
@@ -178,7 +178,7 @@ class MiniGCDataset(DGLDataset):
...
@@ -178,7 +178,7 @@ class MiniGCDataset(DGLDataset):
for
i
in
range
(
self
.
num_graphs
):
for
i
in
range
(
self
.
num_graphs
):
# convert to DGLGraph, and add self loops
# convert to DGLGraph, and add self loops
self
.
graphs
[
i
]
=
add_self_loop
(
from_networkx
(
self
.
graphs
[
i
]))
self
.
graphs
[
i
]
=
add_self_loop
(
from_networkx
(
self
.
graphs
[
i
]))
self
.
labels
=
F
.
tensor
(
np
.
array
(
self
.
labels
).
astype
(
np
.
int
))
self
.
labels
=
F
.
tensor
(
np
.
array
(
self
.
labels
).
astype
(
np
.
int
64
))
def
_gen_cycle
(
self
,
n
):
def
_gen_cycle
(
self
,
n
):
for
_
in
range
(
n
):
for
_
in
range
(
n
):
...
...
python/dgl/data/qm9.py
View file @
0038a29b
...
@@ -182,7 +182,7 @@ class QM9Dataset(DGLDataset):
...
@@ -182,7 +182,7 @@ class QM9Dataset(DGLDataset):
n_atoms
=
self
.
N
[
idx
]
n_atoms
=
self
.
N
[
idx
]
R
=
self
.
R
[
self
.
N_cumsum
[
idx
]:
self
.
N_cumsum
[
idx
+
1
]]
R
=
self
.
R
[
self
.
N_cumsum
[
idx
]:
self
.
N_cumsum
[
idx
+
1
]]
dist
=
np
.
linalg
.
norm
(
R
[:,
None
,
:]
-
R
[
None
,
:,
:],
axis
=-
1
)
dist
=
np
.
linalg
.
norm
(
R
[:,
None
,
:]
-
R
[
None
,
:,
:],
axis
=-
1
)
adj
=
sp
.
csr_matrix
(
dist
<=
self
.
cutoff
)
-
sp
.
eye
(
n_atoms
,
dtype
=
np
.
bool
)
adj
=
sp
.
csr_matrix
(
dist
<=
self
.
cutoff
)
-
sp
.
eye
(
n_atoms
,
dtype
=
np
.
bool
_
)
adj
=
adj
.
tocoo
()
adj
=
adj
.
tocoo
()
u
,
v
=
F
.
tensor
(
adj
.
row
),
F
.
tensor
(
adj
.
col
)
u
,
v
=
F
.
tensor
(
adj
.
row
),
F
.
tensor
(
adj
.
col
)
g
=
dgl_graph
((
u
,
v
))
g
=
dgl_graph
((
u
,
v
))
...
...
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