Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiang Song committed Dec 14, 2023
1 parent 007fa8e commit f87d4a5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/end2end-tests/data_process/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,3 +204,14 @@ def read_data_parquet(data_file):
edge_label_stats = json.load(f)
assert ("node1,relation1,node2") in edge_label_stats
assert "label" in edge_label_stats[("node1,relation1,node2")]

# Test hard negatives
hard_neg = g.edges[('node1', 'relation2', 'node1')].data["hard_neg"]
src_ids, dst_ids = g.edges(etype=("node1", "relation2", "node1"))
ground_truth = th.cat((src_ids.reshape(-1,1), dst_ids.reshape(-1,1)), dim=1)
assert th.sum(hard_neg-ground_truth) == 0

hard_neg = g.edges[("node2", "relation3", "node3")].data["hard_neg"]
_, dst_ids = g.edges(etype=("node2", "relation3", "node3"))
ground_truth = th.cat((dst_ids.reshape(-1,1), dst_ids.reshape(-1,1)), dim=1)
assert th.sum(hard_neg-ground_truth) == 0

0 comments on commit f87d4a5

Please sign in to comment.