Skip to content

Comments

Dynamically update edge names#511

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

Dynamically update edge names#511
naik-aakash wants to merge 7 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 😄

@naik-aakash
Copy link
Author

Hi @minhsueh

I am confused, how is suppose to work then ? I think it will again overwrite whatever edge_weight_name is set during creation of molecule object using the edge_weight_name arg currently added to the function with whatever is set in edge_weight_name_mapping. Do you mean I remove the edge_weight_name arg ?

            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}"

Now , For example in my other PR, Where is edge_weight_name_mapping dict as kwarg suppose to be passed in my code ? Do not see any obvious way
https://github.com/JaGeo/crystaltoolkit/blob/f8a615c2758ec77ee7d1437f8507034c1e8e07d4/crystal_toolkit/components/localenv.py#L285

@naik-aakash
Copy link
Author

Hi @minhsueh

I am confused, how is suppose to work then ? I think it will again overwrite whatever edge_weight_name is set during creation of molecule object using the edge_weight_name arg currently added to the function with whatever is set in edge_weight_name_mapping. Do you mean I remove the edge_weight_name arg ?

            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}"

Now , For example in my other PR, Where is edge_weight_name_mapping dict as kwarg suppose to be passed in my code ? Do not see any obvious way https://github.com/JaGeo/crystaltoolkit/blob/f8a615c2758ec77ee7d1437f8507034c1e8e07d4/crystal_toolkit/components/localenv.py#L285

Nevermind, I got it working seems. Maybe have a look and let me know if this is fine now.

@minhsueh
Copy link
Collaborator

Thanks! @naik-aakash
Sorry for leaving messages in multiple code places — I should have provided a single, clear comment instead.

As you’ve noticed, we use the edge_weight_name defined during molecule creation. The edge_weight_name_mapping simply serves as an additional check to determine whether a different display label should be applied.

This allows users to modify the MoleculeGraph by setting edge_weight_name and edge_weight_units directly, without needing to change lower-level modules or the site scene generation logic.

@naik-aakash
Copy link
Author

naik-aakash commented Feb 23, 2026

Thanks! @naik-aakash Sorry for leaving messages in multiple code places — I should have provided a single, clear comment instead.

As you’ve noticed, we use the edge_weight_name defined during molecule creation. The edge_weight_name_mapping simply serves as an additional check to determine whether a different display label should be applied.

This allows users to modify the MoleculeGraph by setting edge_weight_name and edge_weight_units directly, without needing to change lower-level modules or the site scene generation logic.

Thanks, took me some while to understand. Hope now the changes don't break any of the existing behavior 😅

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