Skip to content

Comments

Dynamically update edge names#511

Open
naik-aakash wants to merge 3 commits intomaterialsproject:mainfrom
naik-aakash:update_site_prop
Open

Dynamically update edge names#511
naik-aakash wants to merge 3 commits intomaterialsproject:mainfrom
naik-aakash:update_site_prop

Conversation

@naik-aakash
Copy link

@naik-aakash naik-aakash commented Feb 20, 2026

Changes

Remove the hardcoded bond-order hover text in the molecule scene, and update edge names dynamically based on the set edge_weight_name property of the molecule graph when it is set. If not set, then only use bond order as hover text .

@naik-aakash
Copy link
Author

Hi @minhsueh and @esoteric-ephemera, if this change fine ? If yes could be merged 😄

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}"
if edge_weight_name is None:
Copy link
Collaborator

@minhsueh minhsueh Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vis_mol_graph.edge_weight_name is "weight", so this modification makes the bond label from "bond order:1.00" to "weight:1.00", as the attached images show.

We might want

if edge_weight_name is None or edge_weight_name == "weight":

to keep the default behavior unchanged. This is also not ideal, as if you want to show "weight", then it will always be "bond order."

Something to think about is using another key-value mapping for better customization
like

                if edge_weight_name is None:
                    edge_weight_name = "bond order"
                edge_weight_name = edge_weight_name_mapping.get(edge_weight_name, edge_weight_name)
                name_cyl = f"{edge_weight_name}:{connected_site.weight:.2f}"
Image Image

retain_atom_idx: bool = False,
total_repeat_cell_cnt: int = 1,
edge_weight_name: str = "bond order",
edge_weight_unit: str = "",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

    edge_weight_name_mapping: dict[str, str] = {"weight": "bond order"},

show_atom_coord=True,
show_bond_order=True,
show_bond_length=False,
visualize_bond_orders=False,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

site_get_scene_kwargs: dict | None = None, for keyword arguments to pass to Site.get_scene to support edge_weight_name_mapping.

Similar implementation in structuregraph.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants