Skip to content

Commit

Permalink
Shift handling to stk functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtarzia committed Sep 24, 2024
1 parent 38e5cb5 commit 754a184
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
3 changes: 1 addition & 2 deletions python/chemiscope/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,7 @@ def create_input(
# Check to tell the user they might have forgotten some properties coming
# from the frames (that chemiscope used to automatically extract). This code
# should be removed in version 0.6 of chemiscope.
# stk cannot have atom properties or structure properties, so skipping.
if frames is not None and not from_stk:
if frames is not None:
found_one_from_frame = False

atom_properties = _list_atom_properties(frames)
Expand Down
13 changes: 7 additions & 6 deletions python/chemiscope/structures/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
convert_stk_bonds_as_shapes,
_stk_all_atomic_environments,
_stk_composition_properties,
_stk_list_atom_properties,
_stk_list_structure_properties,
)

__all__ = [
Expand Down Expand Up @@ -83,9 +85,9 @@ def _list_atom_properties(frames):
if adapter == "ASE":
return _ase_list_atom_properties(frames)
elif adapter == "stk":
# Do not check, because stk does not contain its own properties
# and a dictionary must be added.
pass
# stk does not contain properties inside the structure objects.
return _stk_list_atom_properties(frames)

else:
raise Exception("reached unreachable code")

Expand All @@ -101,9 +103,8 @@ def _list_structure_properties(frames):
if adapter == "ASE":
return _ase_list_structure_properties(frames)
elif adapter == "stk":
# Do not check, because stk does not contain its own properties
# and a dictionary must be added.
pass
# stk does not contain properties inside the structure objects.
return _stk_list_structure_properties(frames)
else:
raise Exception("reached unreachable code")

Expand Down
17 changes: 15 additions & 2 deletions python/chemiscope/structures/_stk.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ def _stk_to_json(molecule: stk.Molecule) -> dict[str : int | list]:
return data


def _stk_all_atomic_environments(frames, cutoff):
"Extract all atomic environments out of a set of ASE Atoms objects"
def _stk_all_atomic_environments(
frames: list[stk.Molecule],
cutoff: float,
) -> list[tuple[int, int, float]]:
"Extract all atomic environments out of a set of stk Molecule objects"
environments = []
for structure_i, frame in enumerate(frames):
for atom in frame.get_atoms():
Expand Down Expand Up @@ -196,3 +199,13 @@ def convert_stk_bonds_as_shapes(
shape_dict[bname]["parameters"]["structure"].append(fake_bond)

return shape_dict


def _stk_list_atom_properties(frames: list[stk.Molecule]) -> list:
# stk cannot have atom properties or structure properties, so skipping.
return []


def _stk_list_structure_properties(frames: list[stk.Molecule]) -> list:
# stk cannot have atom properties or structure properties, so skipping.
return []

0 comments on commit 754a184

Please sign in to comment.