Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use displayed_structure to create selection info #371

Merged
merged 34 commits into from
Jan 9, 2023
Merged
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
6650466
use displayed_structure to create selection info
superstar54 Oct 18, 2022
720ae1f
Merge branch 'master' into fix_supercell_selection
superstar54 Nov 22, 2022
2b369ab
add info_unit_cell_atoms
superstar54 Nov 22, 2022
9bac99b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 22, 2022
e05a28e
add displayed_selection
superstar54 Nov 22, 2022
fd8c279
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 22, 2022
129fb82
Merge branch 'master' into fix_supercell_selection
superstar54 Dec 12, 2022
94e30b7
Update aiidalab_widgets_base/viewers.py
superstar54 Dec 12, 2022
8b3f5e4
Update aiidalab_widgets_base/viewers.py
superstar54 Dec 12, 2022
a68ac08
do not update selection formula
superstar54 Dec 12, 2022
8f13226
add a bulk pt for test
superstar54 Dec 12, 2022
f90f8b4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 12, 2022
a157ab8
use try for advance parse_advanced_sel
superstar54 Dec 12, 2022
6f6dbda
Merge branch 'master' into fix_supercell_selection
yakutovicha Dec 14, 2022
2b15fab
Fix dihedral representation
yakutovicha Dec 14, 2022
7311d66
Remove automatic switching to the selection tab.
yakutovicha Dec 14, 2022
cefff7f
Please flake8
yakutovicha Dec 14, 2022
482172d
Update self.selection after self.displayed_selection
yakutovicha Dec 14, 2022
277d80e
Apply selection to display_structure
yakutovicha Dec 14, 2022
e56b5d6
Tests: upload screenshots also in case of failure.
yakutovicha Dec 15, 2022
e746510
Remove leftovers from testing
yakutovicha Dec 15, 2022
ee21af9
fix test
yakutovicha Dec 15, 2022
b50e84c
Trying to test supercell selection
yakutovicha Dec 15, 2022
48d7849
fix
yakutovicha Dec 15, 2022
a13d260
Fix tests
yakutovicha Dec 15, 2022
746b603
Revert changes to the tests
yakutovicha Dec 15, 2022
8505ea6
(tests) More robust cell expansion in z-direction.
yakutovicha Dec 19, 2022
9b6fc31
Slightly increase the size of supercell selection widgets
yakutovicha Jan 5, 2023
f2d5f19
Introduce 'input_selection' trait to interact with editors
yakutovicha Jan 5, 2023
d4fccda
Merge branch 'master' into fix_supercell_selection
yakutovicha Jan 9, 2023
b998203
Fix pre-commit
yakutovicha Jan 9, 2023
58b641a
Update tests/test_notebooks.py
yakutovicha Jan 9, 2023
a2fd1e7
Selected atoms -> Select atoms.
yakutovicha Jan 9, 2023
010c899
Fix tests
yakutovicha Jan 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions aiidalab_widgets_base/viewers.py
Original file line number Diff line number Diff line change
Expand Up @@ -997,20 +997,26 @@ def add_info(indx, atom):

# Find geometric center.
geom_center = print_pos(
np.average(self.structure[self.selection].get_positions(), axis=0)
np.average(self.displayed_structure[self.selection].get_positions(), axis=0)
)

# Report coordinates.
if len(self.selection) == 1:
return add_info(self.selection[0], self.structure[self.selection[0]])
return add_info(
self.selection[0], self.displayed_structure[self.selection[0]]
)

# Report coordinates, distance and center.
if len(self.selection) == 2:
info = ""
info += add_info(self.selection[0], self.structure[self.selection[0]])
info += add_info(self.selection[1], self.structure[self.selection[1]])
dist = self.structure.get_distance(*self.selection)
distv = self.structure.get_distance(*self.selection, vector=True)
info += add_info(
self.selection[0], self.displayed_structure[self.selection[0]]
)
info += add_info(
self.selection[1], self.displayed_structure[self.selection[1]]
)
dist = self.displayed_structure.get_distance(*self.selection)
distv = self.displayed_structure.get_distance(*self.selection, vector=True)
info += f"Distance: {dist:.2f} ({print_pos(distv)})<br>Geometric center: ({geom_center})"
return info

Expand All @@ -1020,9 +1026,9 @@ def add_info(indx, atom):

# Report angle geometric center and normal.
if len(self.selection) == 3:
angle = self.structure.get_angle(*self.selection).round(2)
angle = self.displayed_structure.get_angle(*self.selection).round(2)
normal = np.cross(
*self.structure.get_distances(
*self.displayed_structure.get_distances(
self.selection[1],
[self.selection[0], self.selection[2]],
mic=False,
Expand All @@ -1035,7 +1041,9 @@ def add_info(indx, atom):
# Report dihedral angle and geometric center.
if len(self.selection) == 4:
try:
dihedral = self.structure.get_dihedral(self.selection) * 180 / np.pi
dihedral = (
self.displayed_structure.get_dihedral(self.selection) * 180 / np.pi
)
dihedral_str = f"{dihedral:.2f}"
except ZeroDivisionError:
dihedral_str = "nan"
Expand Down