Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Misc] Fix edge_ids()'s error messages #7434

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions python/dgl/heterograph.py
Original file line number Diff line number Diff line change
Expand Up @@ -3262,10 +3262,11 @@ def edge_ids(self, u, v, return_uv=False, etype=None):
# Raise error since some (u, v) pair is not a valid edge.
idx = F.nonzero_1d(is_neg_one)
raise DGLError(
"Error: (%d, %d) does not form a valid edge."
"Error: %d invalid edges, (%d, %d) is one."
% (
F.as_scalar(F.gather_row(u, idx)),
F.as_scalar(F.gather_row(v, idx)),
len(idx),
F.as_scalar(F.gather_row(u, idx[0])),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's ok to print all the invalid node pairs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can't now, there will be an error "ValueError: only one element tensors can be converted to Python scalars" when calling as_scalar(), and will not print any data, so I change it.

F.as_scalar(F.gather_row(v, idx[0])),
)
)
return F.as_scalar(eid) if is_int else eid
Expand Down
Loading