Fix #553: Handle visualization of empty graphs#562
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #562 +/- ##
==========================================
+ Coverage 90.58% 90.62% +0.04%
==========================================
Files 49 49
Lines 7481 7481
==========================================
+ Hits 6777 6780 +3
+ Misses 704 701 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| if not og.graph.nodes: | ||
| return GraphVisualizer( | ||
| og=og, | ||
| pos={}, | ||
| edge_paths={}, | ||
| options=options, | ||
| _source=_Source.OG, | ||
| ) |
There was a problem hiding this comment.
I would add the following lines at the beginning of _compute_positions for OpenGraph:
if not obj.graph.nodes:
return {}The idea is that we don't need a special execution path here and to re‑specify all of the arguments for GraphVisualizer.
There was a problem hiding this comment.
You are right, much cleaner this way. Done in 9daa53a
| if not flow.og.graph.nodes: | ||
| return GraphVisualizer( | ||
| og=flow.og, | ||
| pos={}, | ||
| edge_paths={}, | ||
| options=options, | ||
| _source=_Source.Flow, | ||
| ) |
There was a problem hiding this comment.
Do we need this? I think the default behavior should be sufficient.
| if not xz_corr.og.graph.nodes: | ||
| return GraphVisualizer( | ||
| og=xz_corr.og, | ||
| pos={}, | ||
| edge_paths={}, | ||
| options=options, | ||
| _source=_Source.XZCorr, | ||
| ) |
There was a problem hiding this comment.
Do we need this? I think the default behavior should be sufficient.
Visualization methods yield an empty canvas instead of raising a
ValueErrorwhen called on an empty graph.