Skip to content

Commit f1c0725

Browse files
fix: use self.nodes() in Diagram.__init__ to populate nodes_to_show
The custom __iter__ only yields from nodes_to_show, creating a chicken-and-egg problem: when __init__ used 'for node in self:' to populate nodes_to_show for a schema source, nodes_to_show was still empty so __iter__ yielded nothing, leaving nodes_to_show empty. Fix: replace 'for node in self:' with 'for node in self.nodes()' which calls the inherited nx.DiGraph node iterator directly, independent of nodes_to_show. Fixes test_erd and all Diagram tests that failed due to empty graphs. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
1 parent d05cbdd commit f1c0725

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/datajoint/diagram.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def __init__(self, source, context=None) -> None:
140140
database = source.schema.database
141141
except AttributeError:
142142
raise DataJointError("Cannot plot Diagram for %s" % repr(source))
143-
for node in self:
143+
for node in self.nodes():
144144
# Handle both MySQL backticks and PostgreSQL double quotes
145145
if node.startswith("`%s`" % database) or node.startswith('"%s"' % database):
146146
self.nodes_to_show.add(node)

0 commit comments

Comments
 (0)