Skip to content

Commit dcd3858

Browse files
committed
fix id if only a single structure is provided
1 parent d19cc94 commit dcd3858

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/optimade_maker/convert.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,9 @@ def _set_unique_entry_ids(entry_ids: list[str]) -> list[str]:
321321
322322
"""
323323

324+
if len(entry_ids) == 1:
325+
return [os.path.splitext(os.path.basename(entry_ids[0]))[0]]
326+
324327
new_ids: list[str] = list(entry_ids)
325328

326329
def _strip_common_path(ids, from_back=False):

tests/test_convert.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,8 @@ def test_unique_id_generator():
158158
"set2/3.xyz",
159159
"set2/4.xyz",
160160
]
161+
162+
entry_ids = [
163+
"data/structures/1.cif",
164+
]
165+
assert _set_unique_entry_ids(entry_ids) == ["1"]

0 commit comments

Comments
 (0)