automatic glob of propagations

This commit is contained in:
Benoît Sierro
2023-10-19 10:45:03 +02:00
parent 26e81c4b85
commit 4110579b89

View File

@@ -15,6 +15,7 @@ from scgenerator.io import (
MemoryIOHandler, MemoryIOHandler,
PropagationIOHandler, PropagationIOHandler,
ZipFileIOHandler, ZipFileIOHandler,
logical_sort_key,
unique_name, unique_name,
) )
from scgenerator.logger import get_logger from scgenerator.logger import get_logger
@@ -359,7 +360,9 @@ def propagation(
def propagation_series( def propagation_series(
files: Sequence[os.PathLike], index: int | slice | None = None, progress_bar: bool = False files: Sequence[os.PathLike] | os.PathLike,
index: int | slice | None = None,
progress_bar: bool = False,
) -> tuple[Spectrum, PropagationCollection]: ) -> tuple[Spectrum, PropagationCollection]:
""" """
loads an existing sequence of propagation loads an existing sequence of propagation
@@ -379,6 +382,8 @@ def propagation_series(
PropagationCollection PropagationCollection
convenient object to work with multiple propagations **built on the same grid** convenient object to work with multiple propagations **built on the same grid**
""" """
if isinstance(files, str) or not isinstance(files, Sequence):
files = sorted(Path(files).glob("*.zip"), key=logical_sort_key)
if len(files) == 0: if len(files) == 0:
raise ValueError("You must provide at least one file to build a propagation series") raise ValueError("You must provide at least one file to build a propagation series")