Dynamically update edge names#511
Conversation
|
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: |
There was a problem hiding this comment.
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}"
| retain_atom_idx: bool = False, | ||
| total_repeat_cell_cnt: int = 1, | ||
| edge_weight_name: str = "bond order", | ||
| edge_weight_unit: str = "", |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
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 .