Skip to content

Commit

Permalink
Merge 5a9c050 into d9ee96a
Browse files Browse the repository at this point in the history
  • Loading branch information
sgbaird committed Jun 14, 2022
2 parents d9ee96a + 5a9c050 commit e39fd1a
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/xtal2png/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,10 @@ def xtal2png(
>>> xc = XtalConverter()
>>> xc.xtal2png(structures, show=False, save=True)
"""
save_names, S = self.process_filepaths_or_structures(structures)
save_names, structures = self.process_filepaths_or_structures(structures)

# convert structures to 3D NumPy Matrices
self.data, self.id_data, self.id_keys = self.structures_to_arrays(S)
self.data, self.id_data, self.id_keys = self.structures_to_arrays(structures)
mn, mx = self.data.min(), self.data.max()
if mn < 0:
warn(
Expand Down Expand Up @@ -234,7 +234,6 @@ def xtal2png(

def process_filepaths_or_structures(self, structures):
save_names: List[str] = []
S: List[Structure] = []
first_is_structure = isinstance(structures[0], Structure)
for i, s in enumerate(structures):
if isinstance(s, str) or isinstance(s, PathLike):
Expand All @@ -243,8 +242,7 @@ def process_filepaths_or_structures(self, structures):
f"structures should be of same datatype, either strs or pymatgen Structures. structures[0] is {type(structures[0])}, but got type {type(s)} for entry {i}" # noqa
)

# load the CIF and convert to a pymatgen Structure
S.append(Structure.from_file(s))
structures[i] = Structure.from_file(s)
save_names.append(Path(str(s)).stem)

elif isinstance(s, Structure):
Expand All @@ -253,14 +251,14 @@ def process_filepaths_or_structures(self, structures):
f"structures should be of same datatype, either strs or pymatgen Structures. structures[0] is {type(structures[0])}, but got type {type(s)} for entry {i}" # noqa
)

S.append(s)
structures[i] = s
save_names.append(construct_save_name(s))
else:
raise ValueError(
f"structures should be of type `str`, `os.PathLike` or `pymatgen.core.structure.Structure`, not {type(S)} (entry {i})" # noqa
)

return save_names, S
return save_names, structures

def png2xtal(
self, images: List[Union[Image.Image, "PathLike"]], save: bool = False
Expand Down

0 comments on commit e39fd1a

Please sign in to comment.