Skip to content

Commit 15ace31

Browse files
authored
[Misc] Using the aliases of builtin types like np.int is deprecated (dmlc#7300)
1 parent 2ff3006 commit 15ace31

File tree

10 files changed

+20
-20
lines changed

10 files changed

+20
-20
lines changed

examples/pytorch/ggnn/train_gc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def main(args):
6060
labels = labels.data.numpy().tolist()
6161
dev_preds += preds
6262
dev_labels += labels
63-
acc = np.equal(dev_labels, dev_preds).astype(np.float).tolist()
63+
acc = np.equal(dev_labels, dev_preds).astype(float).tolist()
6464
acc = sum(acc) / len(acc)
6565
print(f"Epoch {epoch}, Dev acc {acc}")
6666

@@ -80,7 +80,7 @@ def main(args):
8080
labels = labels.data.numpy().tolist()
8181
test_preds += preds
8282
test_labels += labels
83-
acc = np.equal(test_labels, test_preds).astype(np.float).tolist()
83+
acc = np.equal(test_labels, test_preds).astype(float).tolist()
8484
acc = sum(acc) / len(acc)
8585
test_acc_list.append(acc)
8686

examples/pytorch/hilander/utils/evaluate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def evaluate(gt_labels, pred_labels, metric="pairwise"):
4040
"evaluate with {}{}{}".format(TextColors.FATAL, metric, TextColors.ENDC)
4141
):
4242
result = metric_func(gt_labels, pred_labels)
43-
if isinstance(result, np.float):
43+
if isinstance(result, float):
4444
print(
4545
"{}{}: {:.4f}{}".format(
4646
TextColors.OKGREEN, metric, result, TextColors.ENDC

examples/pytorch/mvgrl/graph/dataset.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def process(dataset):
6868
for attr in re.split("[,\s]+", line.strip("\s\n"))
6969
if attr
7070
],
71-
dtype=np.float,
71+
dtype=float,
7272
)
7373
)
7474
else:
@@ -130,7 +130,7 @@ def process(dataset):
130130
f[graph.degree[u[0]]] = 1.0
131131
if "label" in u[1]:
132132
f = np.concatenate(
133-
(np.array(u[1]["label"], dtype=np.float), f)
133+
(np.array(u[1]["label"], dtype=float), f)
134134
)
135135
graph.nodes[u[0]]["feat"] = f
136136
return graphs, pprs

examples/pytorch/ogb/deepwalk/reading_data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,13 +213,13 @@ def __init__(
213213
node_degree = self.G.out_degrees(self.valid_seeds).numpy()
214214
node_degree = np.power(node_degree, 0.75)
215215
node_degree /= np.sum(node_degree)
216-
node_degree = np.array(node_degree * 1e8, dtype=np.int)
216+
node_degree = np.array(node_degree * 1e8, dtype=int)
217217
self.neg_table = []
218218

219219
for idx, node in enumerate(self.valid_seeds):
220220
self.neg_table += [node] * node_degree[idx]
221221
self.neg_table_size = len(self.neg_table)
222-
self.neg_table = np.array(self.neg_table, dtype=np.long)
222+
self.neg_table = np.array(self.neg_table, dtype=int)
223223
del node_degree
224224

225225
def create_sampler(self, i):

examples/pytorch/ogb/line/reading_data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,13 @@ def __init__(
209209
node_degree = self.G.out_degrees(self.valid_nodes).numpy()
210210
node_degree = np.power(node_degree, 0.75)
211211
node_degree /= np.sum(node_degree)
212-
node_degree = np.array(node_degree * 1e8, dtype=np.int)
212+
node_degree = np.array(node_degree * 1e8, dtype=int)
213213
self.neg_table = []
214214

215215
for idx, node in enumerate(self.valid_nodes):
216216
self.neg_table += [node] * node_degree[idx]
217217
self.neg_table_size = len(self.neg_table)
218-
self.neg_table = np.array(self.neg_table, dtype=np.long)
218+
self.neg_table = np.array(self.neg_table, dtype=int)
219219
del node_degree
220220

221221
def create_sampler(self, i):

examples/pytorch/pointcloud/pct/ShapeNet.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def __init__(self, shapenet, mode, num_points, normal_channel=True):
132132
[t.split("\n")[0].split(" ") for t in f.readlines()]
133133
).astype(np.float)
134134
data_list.append(data[:, 0 : self.dim])
135-
label_list.append(data[:, 6].astype(np.int))
135+
label_list.append(data[:, 6].astype(int))
136136
category_list.append(shapenet.synset_dict[fn.split("/")[-2]])
137137
self.data = data_list
138138
self.label = label_list
@@ -157,5 +157,5 @@ def __getitem__(self, i):
157157
if self.mode == "train":
158158
x = self.translate(x, size=self.dim)
159159
x = x.astype(np.float)
160-
y = y.astype(np.int)
160+
y = y.astype(int)
161161
return x, y, cat

examples/pytorch/pointcloud/point_transformer/ShapeNet.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ def __init__(self, shapenet, mode, num_points, normal_channel=True):
130130
with open(fn) as f:
131131
data = np.array(
132132
[t.split("\n")[0].split(" ") for t in f.readlines()]
133-
).astype(np.float)
133+
).astype(float)
134134
data_list.append(data[:, 0 : self.dim])
135-
label_list.append(data[:, 6].astype(np.int))
135+
label_list.append(data[:, 6].astype(int))
136136
category_list.append(shapenet.synset_dict[fn.split("/")[-2]])
137137
self.data = data_list
138138
self.label = label_list
@@ -156,6 +156,6 @@ def __getitem__(self, i):
156156
cat = self.category[i]
157157
if self.mode == "train":
158158
x = self.translate(x, size=self.dim)
159-
x = x.astype(np.float)
160-
y = y.astype(np.int)
159+
x = x.astype(float)
160+
y = y.astype(int)
161161
return x, y, cat

examples/pytorch/pointcloud/pointnet/ShapeNet.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ def __init__(self, shapenet, mode, num_points, normal_channel=True):
130130
with open(fn) as f:
131131
data = np.array(
132132
[t.split("\n")[0].split(" ") for t in f.readlines()]
133-
).astype(np.float)
133+
).astype(float)
134134
data_list.append(data[:, 0 : self.dim])
135-
label_list.append(data[:, 6].astype(np.int))
135+
label_list.append(data[:, 6].astype(int))
136136
category_list.append(shapenet.synset_dict[fn.split("/")[-2]])
137137
self.data = data_list
138138
self.label = label_list
@@ -156,6 +156,6 @@ def __getitem__(self, i):
156156
cat = self.category[i]
157157
if self.mode == "train":
158158
x = self.translate(x, size=self.dim)
159-
x = x.astype(np.float)
160-
y = y.astype(np.int)
159+
x = x.astype(float)
160+
y = y.astype(int)
161161
return x, y, cat
755 KB
Binary file not shown.

examples/pytorch/rrn/sudoku_solver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def solve_sudoku(puzzle):
1313
:param puzzle: an array-like data with shape [9, 9], blank positions are filled with 0
1414
:return: a [9, 9] shaped numpy array
1515
"""
16-
puzzle = np.array(puzzle, dtype=np.long).reshape([-1])
16+
puzzle = np.array(puzzle, dtype=int).reshape([-1])
1717
model_path = "ckpt"
1818
if not os.path.exists(model_path):
1919
os.mkdir(model_path)

0 commit comments

Comments
 (0)