From 8cd8243050bf0f9ed5a4f56893653a36189757e9 Mon Sep 17 00:00:00 2001 From: naik-aakash Date: Fri, 20 Feb 2026 11:21:38 +0100 Subject: [PATCH 1/3] dynamic edge names based on input --- crystal_toolkit/renderables/moleculegraph.py | 3 +++ crystal_toolkit/renderables/site.py | 11 +++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/crystal_toolkit/renderables/moleculegraph.py b/crystal_toolkit/renderables/moleculegraph.py index 4704b8f6..7f4c5329 100644 --- a/crystal_toolkit/renderables/moleculegraph.py +++ b/crystal_toolkit/renderables/moleculegraph.py @@ -62,6 +62,8 @@ def get_molecule_graph_scene( show_bond_length=show_bond_length, visualize_bond_orders=visualize_bond_orders, draw_polyhedra=draw_polyhedra, + edge_weight_name=vis_mol_graph.edge_weight_name, + edge_weight_unit=vis_mol_graph.edge_weight_unit, ) for scene in site_scene.contents: primitives[scene.name] += scene.contents @@ -74,3 +76,4 @@ def get_molecule_graph_scene( MoleculeGraph.get_scene = get_molecule_graph_scene + diff --git a/crystal_toolkit/renderables/site.py b/crystal_toolkit/renderables/site.py index ac9579e9..9ef65194 100644 --- a/crystal_toolkit/renderables/site.py +++ b/crystal_toolkit/renderables/site.py @@ -49,6 +49,8 @@ def get_site_scene( legend: Legend | None = None, retain_atom_idx: bool = False, total_repeat_cell_cnt: int = 1, + edge_weight_name: str = "bond order", + edge_weight_unit: str = "", ) -> Scene: """Get a Scene object for a Site. @@ -74,6 +76,8 @@ def get_site_scene( legend (Legend | None, optional): Defaults to None. retain_atom_idx (bool, optional): Defaults to False. total_repeat_cell_cnt (int, optional): Defaults to 1. + edge_weight_name (str, optional): Defaults to "bond order". + edge_weight_unit (str, optional): Defaults to "". Returns: Scene: The scene object containing atoms, bonds, polyhedra, magmoms. @@ -192,8 +196,10 @@ def get_site_scene( for idx, connected_site in enumerate(connected_sites): if show_bond_order and connected_site.weight is not None: - name_cyl = f"bond order:{connected_site.weight:.2f}" - + name_cyl = f"{edge_weight_name.upper()}:{connected_site.weight:.2f}" + if edge_weight_unit: + name_cyl += f" ({edge_weight_unit})" + if show_bond_length and connected_site.dist is not None: name_cyl += f"\nbond length:{connected_site.dist:.3f}" @@ -360,3 +366,4 @@ def get_site_scene( Site.get_scene = get_site_scene + From d1036fb55a624265a87f2f48af9201f4fd0ff138 Mon Sep 17 00:00:00 2001 From: naik-aakash Date: Fri, 20 Feb 2026 11:22:58 +0100 Subject: [PATCH 2/3] dynamic edge names based on input --- crystal_toolkit/renderables/moleculegraph.py | 1 - crystal_toolkit/renderables/site.py | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/crystal_toolkit/renderables/moleculegraph.py b/crystal_toolkit/renderables/moleculegraph.py index 7f4c5329..71b389df 100644 --- a/crystal_toolkit/renderables/moleculegraph.py +++ b/crystal_toolkit/renderables/moleculegraph.py @@ -76,4 +76,3 @@ def get_molecule_graph_scene( MoleculeGraph.get_scene = get_molecule_graph_scene - diff --git a/crystal_toolkit/renderables/site.py b/crystal_toolkit/renderables/site.py index 9ef65194..c119b019 100644 --- a/crystal_toolkit/renderables/site.py +++ b/crystal_toolkit/renderables/site.py @@ -199,7 +199,7 @@ def get_site_scene( name_cyl = f"{edge_weight_name.upper()}:{connected_site.weight:.2f}" if edge_weight_unit: name_cyl += f" ({edge_weight_unit})" - + if show_bond_length and connected_site.dist is not None: name_cyl += f"\nbond length:{connected_site.dist:.3f}" @@ -366,4 +366,3 @@ def get_site_scene( Site.get_scene = get_site_scene - From f47401bcc703b808f1c9f0216bc4707ee461af1a Mon Sep 17 00:00:00 2001 From: naik-aakash Date: Fri, 20 Feb 2026 11:40:09 +0100 Subject: [PATCH 3/3] remove upper and restore exisitng behaviour of hardcoded bond-order --- crystal_toolkit/renderables/site.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crystal_toolkit/renderables/site.py b/crystal_toolkit/renderables/site.py index c119b019..a2e4ee62 100644 --- a/crystal_toolkit/renderables/site.py +++ b/crystal_toolkit/renderables/site.py @@ -196,7 +196,9 @@ def get_site_scene( for idx, connected_site in enumerate(connected_sites): if show_bond_order and connected_site.weight is not None: - name_cyl = f"{edge_weight_name.upper()}:{connected_site.weight:.2f}" + if edge_weight_name is None: + edge_weight_name = "bond order" + name_cyl = f"{edge_weight_name}:{connected_site.weight:.2f}" if edge_weight_unit: name_cyl += f" ({edge_weight_unit})"