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

Improving error message when wrong frame is provided #120

Merged
merged 3 commits into from
Sep 26, 2024
Merged
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
9 changes: 9 additions & 0 deletions motile/track_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,22 @@
or edges do already exist, the values set in the given ``nx_graph``
will be updating the previously set values.
"""
nodes_count = 0
# add all regular nodes (all but ones representing hyperedges)
for node, data in nx_graph.nodes.items():
if self.frame_attribute in data:
if node not in self.nodes:
self.nodes[node] = data
else:
self.nodes[node] |= data
nodes_count += 1

# graph without nodes, it's very likely this was not intentional
if nodes_count == 0:
raise KeyError(

Check warning on line 135 in motile/track_graph.py

View check run for this annotation

Codecov / codecov/patch

motile/track_graph.py#L135

Added line #L135 was not covered by tests
f"No nodes with `frame_attribute` '{self.frame_attribute}' found in "
"the `nx_graph`.\nIt's likely the wrong `frame_attribute` was set."
)

# add all edges and hyperedges
for (u, v), data in nx_graph.edges.items():
Expand Down
Loading