Skip to content

Commit d75b4dc

Browse files
authored
Merge pull request #312 from gpetretto/devel
fix chemenv view
2 parents 00f8e1c + d8e7ed7 commit d75b4dc

File tree

2 files changed

+31
-26
lines changed

2 files changed

+31
-26
lines changed

crystal_toolkit/components/localenv.py

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
Label,
4040
Loading,
4141
cite_me,
42-
get_data_list,
42+
get_table,
4343
get_tooltip,
4444
)
4545

@@ -786,10 +786,10 @@ def get_valences(struct):
786786
unknown_sites = []
787787

788788
for index, wyckoff in zip(inequivalent_indices, wyckoffs):
789-
datalist = {
790-
"Site": unicodeify_species(struct[index].species_string),
791-
"Wyckoff Label": wyckoff,
792-
}
789+
datalist = [
790+
["Site", unicodeify_species(struct[index].species_string)],
791+
["Wyckoff Label", wyckoff],
792+
]
793793

794794
if not lse.neighbors_sets[index]:
795795
unknown_sites.append(f"{struct[index].species_string} ({wyckoff})")
@@ -822,24 +822,27 @@ def get_valences(struct):
822822
if co.alternative_names:
823823
name += f" (also known as {', '.join(co.alternative_names)})"
824824

825-
datalist.update(
826-
{
827-
"Environment": name,
828-
"IUPAC Symbol": co.IUPAC_symbol_str,
829-
get_tooltip(
830-
"CSM",
831-
"The continuous symmetry measure (CSM) describes the similarity to an "
832-
"ideal coordination environment. It can be understood as a 'distance' to "
833-
"a shape and ranges from 0 to 100 in which 0 corresponds to a "
834-
"coordination environment that is exactly identical to the ideal one. A "
835-
"CSM larger than 5.0 already indicates a relatively strong distortion of "
836-
"the investigated coordination environment.",
837-
): f"{env[0]['csm']:.2f}",
838-
"Interactive View": view,
839-
}
825+
datalist.extend(
826+
[
827+
["Environment", name],
828+
["IUPAC Symbol", co.IUPAC_symbol_str],
829+
[
830+
get_tooltip(
831+
"CSM",
832+
"The continuous symmetry measure (CSM) describes the similarity to an "
833+
"ideal coordination environment. It can be understood as a 'distance' to "
834+
"a shape and ranges from 0 to 100 in which 0 corresponds to a "
835+
"coordination environment that is exactly identical to the ideal one. A "
836+
"CSM larger than 5.0 already indicates a relatively strong distortion of "
837+
"the investigated coordination environment.",
838+
),
839+
f"{env[0]['csm']:.2f}",
840+
],
841+
["Interactive View", view],
842+
]
840843
)
841844

842-
envs.append(get_data_list(datalist))
845+
envs.append(get_table(rows=datalist))
843846

844847
# TODO: switch to tiles?
845848
envs_grouped = [envs[i : i + 2] for i in range(0, len(envs), 2)]

crystal_toolkit/renderables/moleculegraph.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,18 @@ def get_molecule_graph_scene(
3636
A Molecule Graph scene
3737
"""
3838

39-
vis_mol_graph = MoleculeGraph.with_local_env_strategy(self.molecule, OpenBabelNN())
39+
if visualize_bond_orders:
40+
vis_mol_graph = MoleculeGraph.with_local_env_strategy(
41+
self.molecule, OpenBabelNN()
42+
)
43+
else:
44+
vis_mol_graph = self
4045
legend = legend or Legend(self.molecule)
4146

4247
primitives: dict[str, list] = defaultdict(list)
4348

4449
for idx, site in enumerate(self.molecule):
45-
if visualize_bond_orders:
46-
connected_sites = vis_mol_graph.get_connected_sites(idx)
47-
else:
48-
connected_sites = self.get_connected_sites(idx)
50+
connected_sites = vis_mol_graph.get_connected_sites(idx)
4951

5052
site_scene = site.get_scene(
5153
site_idx=idx,

0 commit comments

Comments
 (0)