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

Set structure traitlet to None before assigning new structure #549

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions aiidalab_widgets_base/structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ def _observe_input_structure(self, change):
# If the `input_structure` trait is set to Atoms object, then the `structure` trait should be set to it as well.
self.history = []

self.structure = None
if isinstance(change["new"], ase.Atoms):
self.structure = change["new"]

Expand All @@ -327,9 +328,6 @@ def _observe_input_structure(self, change):
elif isinstance(change["new"], StructureData):
self.structure = change["new"].get_ase()

else:
self.structure = None

@tl.observe("structure")
def _structure_changed(self, change=None):
"""Perform some operations that depend on the value of `structure` trait.
Expand Down Expand Up @@ -408,6 +406,7 @@ def _validate_and_fix_ase_cell(self, ase_structure, vacuum_ang=10.0):

def _on_file_upload(self, change=None):
"""When file upload button is pressed."""
self.structure = None
for fname, item in change["new"].items():
self.structure = self._read_structure(fname, item["content"])
self.file_upload.value.clear()
Expand Down Expand Up @@ -782,6 +781,7 @@ def _on_button_pressed(self, change=None):
"""Convert SMILES to ASE structure when button is pressed."""
self.output.value = ""

self.structure = None
if not self.smiles.value:
return
spinner = f"Screening possible conformers {self.SPINNER}" # font-size:20em;
Expand Down