diff --git a/tests/test_configset.py b/tests/test_configset.py index 881053af..60eace59 100644 --- a/tests/test_configset.py +++ b/tests/test_configset.py @@ -130,7 +130,7 @@ def test_mult_files_mult_Atoms_glob_dir(tmp_path, ats): (tmp_path / "dir_0").mkdir() (tmp_path / "dir_1").mkdir() ase.io.write(tmp_path / "dir_0" / "ats.xyz", ats[0:5]) - ase.io.write(tmp_path / "dir_1" /"ats.xyz", ats[5:10]) + ase.io.write(tmp_path / "dir_1" / "ats.xyz", ats[5:10]) locs = [f" / {i0} / {i1}" for i0 in range(2) for i1 in range(5)] # glob for dir name, but same filename diff --git a/wfl/configset.py b/wfl/configset.py index 7a3bb009..3974c611 100644 --- a/wfl/configset.py +++ b/wfl/configset.py @@ -84,7 +84,7 @@ def __init__(self, items, *, file_root=None, read_kwargs={}, _open_reader=None, raise ValueError(f"Got file_root but file {items} is an absolute path") # single item, could be a simple filename or a glob. Former needs to be stored as # Path, latter as list(Path) - items_expanded = [Path(f) for f in glob.glob(str(file_root / items), recursive=True)] + items_expanded = [Path(f) for f in sorted(glob.glob(str(file_root / items), recursive=True))] if len(items_expanded) == 1 and file_root / items == items_expanded[0]: self.items = file_root / items else: @@ -95,7 +95,7 @@ def __init__(self, items, *, file_root=None, read_kwargs={}, _open_reader=None, assert isinstance(file_path, (str, Path)) if file_root != Path("") and Path(file_path).is_absolute(): raise ValueError(f"Got file_root but file {file_path} is an absolute path") - self.items.extend([Path(f) for f in glob.glob(str(file_root / file_path), recursive=True)]) + self.items.extend([Path(f) for f in sorted(glob.glob(str(file_root / file_path), recursive=True))]) elif isinstance(items[0], ConfigSet): self.items = [] for item in items: