Skip to content

Commit

Permalink
fix unittest bug
Browse files Browse the repository at this point in the history
  • Loading branch information
DesmonDay committed Aug 8, 2022
1 parent 0a8d596 commit 554485a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 27 deletions.
Expand Up @@ -262,7 +262,7 @@ def func_sample_result(self):
nodes = paddle.to_tensor(self.nodes)

edge_src, edge_dst, sample_index, reindex_nodes = \
paddle.geometric.graph_khop_sampler(row, colptr,
paddle.geometric.khop_sampler(row, colptr,
nodes, self.sample_sizes,
return_eids=False)
# Reindex edge_src and edge_dst to original index.
Expand Down Expand Up @@ -311,7 +311,7 @@ def func_uva_sample_result(self):
nodes = paddle.to_tensor(self.nodes)

edge_src, edge_dst, sample_index, reindex_nodes, edge_eids = \
paddle.geometric.graph_khop_sampler(row, colptr,
paddle.geometric.khop_sampler(row, colptr,
nodes, self.sample_sizes,
sorted_eids=sorted_eid,
return_eids=True)
Expand Down Expand Up @@ -357,7 +357,7 @@ def test_sample_result_static_with_eids(self):
dtype=self.nodes.dtype)

edge_src, edge_dst, sample_index, reindex_nodes, edge_eids = \
paddle.geometric.graph_khop_sampler(row, colptr,
paddle.geometric.khop_sampler(row, colptr,
nodes, self.sample_sizes,
sorted_eids, True)
exe = paddle.static.Executor(paddle.CPUPlace())
Expand Down Expand Up @@ -403,7 +403,7 @@ def test_sample_result_static_without_eids(self):
shape=self.nodes.shape,
dtype=self.nodes.dtype)
edge_src, edge_dst, sample_index, reindex_nodes = \
paddle.geometric.graph_khop_sampler(row, colptr,
paddle.geometric.khop_sampler(row, colptr,
nodes, self.sample_sizes)
exe = paddle.static.Executor(paddle.CPUPlace())
ret = exe.run(feed={
Expand Down
34 changes: 16 additions & 18 deletions python/paddle/fluid/tests/unittests/test_graph_sample_neighbors.py
Expand Up @@ -254,7 +254,7 @@ def test_sample_result(self):
colptr = paddle.to_tensor(self.colptr)
nodes = paddle.to_tensor(self.nodes)

out_neighbors, out_count = paddle.geometric.graph_sample_neighbors(
out_neighbors, out_count = paddle.geometric.sample_neighbors(
row, colptr, nodes, sample_size=self.sample_size)
out_count_cumsum = paddle.cumsum(out_count)
for i in range(len(out_count)):
Expand Down Expand Up @@ -283,7 +283,7 @@ def test_sample_result_fisher_yates_sampling(self):
nodes = paddle.to_tensor(self.nodes)
perm_buffer = paddle.to_tensor(self.edges_id)

out_neighbors, out_count = paddle.geometric.graph_sample_neighbors(
out_neighbors, out_count = paddle.geometric.sample_neighbors(
row,
colptr,
nodes,
Expand Down Expand Up @@ -322,7 +322,7 @@ def test_sample_result_static(self):
shape=self.nodes.shape,
dtype=self.nodes.dtype)

out_neighbors, out_count = paddle.geometric.graph_sample_neighbors(
out_neighbors, out_count = paddle.geometric.sample_neighbors(
row, colptr, nodes, sample_size=self.sample_size)
exe = paddle.static.Executor(paddle.CPUPlace())
ret = exe.run(feed={
Expand Down Expand Up @@ -350,20 +350,18 @@ def test_raise_errors(self):
nodes = paddle.to_tensor(self.nodes)

def check_eid_error():
paddle.geometric.graph_sample_neighbors(
row,
colptr,
nodes,
sample_size=self.sample_size,
return_eids=True)
paddle.geometric.sample_neighbors(row,
colptr,
nodes,
sample_size=self.sample_size,
return_eids=True)

def check_perm_buffer_error():
paddle.geometric.graph_sample_neighbors(
row,
colptr,
nodes,
sample_size=self.sample_size,
flag_perm_buffer=True)
paddle.geometric.sample_neighbors(row,
colptr,
nodes,
sample_size=self.sample_size,
flag_perm_buffer=True)

self.assertRaises(ValueError, check_eid_error)
self.assertRaises(ValueError, check_perm_buffer_error)
Expand All @@ -376,15 +374,15 @@ def test_sample_result_with_eids(self):
eids = paddle.to_tensor(self.edges_id)
perm_buffer = paddle.to_tensor(self.edges_id)

out_neighbors, out_count, out_eids = paddle.geometric.graph_sample_neighbors(
out_neighbors, out_count, out_eids = paddle.geometric.sample_neighbors(
row,
colptr,
nodes,
eids=eids,
sample_size=self.sample_size,
return_eids=True)

out_neighbors, out_count, out_eids = paddle.geometric.graph_sample_neighbors(
out_neighbors, out_count, out_eids = paddle.geometric.sample_neighbors(
row,
colptr,
nodes,
Expand All @@ -409,7 +407,7 @@ def test_sample_result_with_eids(self):
shape=self.edges_id.shape,
dtype=self.nodes.dtype)

out_neighbors, out_count, out_eids = paddle.geometric.graph_sample_neighbors(
out_neighbors, out_count, out_eids = paddle.geometric.sample_neighbors(
row,
colptr,
nodes,
Expand Down
8 changes: 4 additions & 4 deletions python/paddle/fluid/tests/unittests/test_segment_ops.py
Expand Up @@ -75,13 +75,13 @@ def compute_segment_min_max(x, segment_ids, pooltype="MAX"):

def segment_pool_split(X, SegmentIds, pooltype):
if pooltype == "SUM":
return paddle.incubate.tensor.segment_sum(X, SegmentIds)
return paddle.geometric.segment_sum(X, SegmentIds)
elif pooltype == "MEAN":
return paddle.incubate.tensor.segment_mean(X, SegmentIds)
return paddle.geometric.segment_mean(X, SegmentIds)
elif pooltype == "MIN":
return paddle.incubate.tensor.segment_min(X, SegmentIds)
return paddle.geometric.segment_min(X, SegmentIds)
elif pooltype == "MAX":
return paddle.incubate.tensor.segment_max(X, SegmentIds)
return paddle.geometric.segment_max(X, SegmentIds)


class TestSegmentOps(OpTest):
Expand Down
2 changes: 1 addition & 1 deletion python/paddle/geometric/sampling/khop_sampler.py
Expand Up @@ -81,7 +81,7 @@ def khop_sampler(row,
nodes = paddle.to_tensor(nodes, dtype="int64")
edge_src, edge_dst, sample_index, reindex_nodes = \
paddle.geometric.graph_khop_sampler(row, colptr, nodes, sample_sizes, False)
paddle.geometric.khop_sampler(row, colptr, nodes, sample_sizes, False)
"""

Expand Down

0 comments on commit 554485a

Please sign in to comment.