From 7cb771edc2134375bfa926b2a56f10549418a83f Mon Sep 17 00:00:00 2001 From: Dimitri Yatsenko Date: Fri, 6 Feb 2026 09:43:43 -0600 Subject: [PATCH 1/2] fix: Strip module prefix correctly for Part tables in diagrams Previously, Part table names like `scan.Scans.Scan` would display with the full module prefix because the logic used rsplit(".", 1) which only split at the last dot. This meant the prefix `scan.Scans` didn't match the cluster label `scan`. Now uses startswith() to check if the name begins with the cluster label, then strips that prefix. This correctly displays Part tables as `Scans.Scan` instead of `scan.Scans.Scan`. Fixes #1390 Co-Authored-By: Claude Opus 4.5 --- src/datajoint/diagram.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/datajoint/diagram.py b/src/datajoint/diagram.py index 48e18fd0d..78412a65c 100644 --- a/src/datajoint/diagram.py +++ b/src/datajoint/diagram.py @@ -759,9 +759,9 @@ def make_dot(self): display_name = name schema_name = schema_map.get(name) if schema_name and "." in name: - prefix = name.rsplit(".", 1)[0] - if prefix == cluster_labels.get(schema_name): - display_name = name.rsplit(".", 1)[1] + cluster_label = cluster_labels.get(schema_name) + if cluster_label and name.startswith(cluster_label + "."): + display_name = name[len(cluster_label) + 1:] node.set_label("<" + display_name + ">" if node.get("distinguished") == "True" else display_name) node.set_color(props["color"]) node.set_style("filled") @@ -959,10 +959,8 @@ def make_mermaid(self) -> str: cls = tier_class.get(tier, "") # Strip module prefix from display name if it matches the cluster label display_name = node - if "." in node: - prefix = node.rsplit(".", 1)[0] - if prefix == label: - display_name = node.rsplit(".", 1)[1] + if "." in node and node.startswith(label + "."): + display_name = node[len(label) + 1:] class_suffix = f":::{cls}" if cls else "" lines.append(f" {safe_id}{left}{display_name}{right}{class_suffix}") lines.append(" end") From 5435e26f2d5575943afedd724ae398dea46fb94d Mon Sep 17 00:00:00 2001 From: Dimitri Yatsenko Date: Fri, 6 Feb 2026 09:46:07 -0600 Subject: [PATCH 2/2] style: Format slice notation --- src/datajoint/diagram.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/datajoint/diagram.py b/src/datajoint/diagram.py index 78412a65c..7034d122b 100644 --- a/src/datajoint/diagram.py +++ b/src/datajoint/diagram.py @@ -761,7 +761,7 @@ def make_dot(self): if schema_name and "." in name: cluster_label = cluster_labels.get(schema_name) if cluster_label and name.startswith(cluster_label + "."): - display_name = name[len(cluster_label) + 1:] + display_name = name[len(cluster_label) + 1 :] node.set_label("<" + display_name + ">" if node.get("distinguished") == "True" else display_name) node.set_color(props["color"]) node.set_style("filled") @@ -960,7 +960,7 @@ def make_mermaid(self) -> str: # Strip module prefix from display name if it matches the cluster label display_name = node if "." in node and node.startswith(label + "."): - display_name = node[len(label) + 1:] + display_name = node[len(label) + 1 :] class_suffix = f":::{cls}" if cls else "" lines.append(f" {safe_id}{left}{display_name}{right}{class_suffix}") lines.append(" end")