Skip to content

Commit 0cc18d7

Browse files
committed
Add reverse flag to fit_sequential for reverse-order processing
1 parent e1ac6c2 commit 0cc18d7

5 files changed

Lines changed: 17 additions & 5 deletions

File tree

.github/workflows/cleanup.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ jobs:
7373
permissions:
7474
actions: write
7575

76-
7776
steps:
7877
- name: Delete workflow runs
7978
uses: Mattraks/delete-workflow-runs@v2

pixi.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,8 @@ convention = 'numpy'
372372
[tool.ruff.lint.pylint]
373373
# Ruff counts `self`/`cls` in max-args; traditional pylint does not.
374374
# Setting 6 here matches pylint's default of 5 (excluding self).
375-
max-args = 6
376-
max-positional-args = 6
375+
max-args = 7
376+
max-positional-args = 7
377377

378378
#############################
379379
# Configuration for pydoclint

src/easydiffraction/analysis/analysis.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,7 @@ def fit_sequential(
905905
file_pattern: str = '*',
906906
extract_diffrn: object = None,
907907
verbosity: str | None = None,
908+
reverse: bool = False,
908909
) -> None:
909910
"""
910911
Run sequential fitting over all data files in a directory.
@@ -936,6 +937,10 @@ def fit_sequential(
936937
verbosity : str | None, default=None
937938
``'full'``, ``'short'``, or ``'silent'``. Default: project
938939
verbosity.
940+
reverse : bool, default=False
941+
When ``True``, process data files in reverse order. Useful
942+
when starting values are better matched to the last file
943+
(e.g. highest-temperature dataset in a cooling scan).
939944
"""
940945
from easydiffraction.analysis.sequential import fit_sequential as _fit_seq # noqa: PLC0415
941946

@@ -955,6 +960,7 @@ def fit_sequential(
955960
chunk_size=chunk_size,
956961
file_pattern=file_pattern,
957962
extract_diffrn=extract_diffrn,
963+
reverse=reverse,
958964
)
959965
finally:
960966
if original_verbosity is not None:

src/easydiffraction/analysis/sequential.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,7 @@ def fit_sequential(
811811
chunk_size: int | None = None,
812812
file_pattern: str = '*',
813813
extract_diffrn: Callable | None = None,
814+
reverse: bool = False,
814815
) -> None:
815816
"""
816817
Run sequential fitting over all data files in a directory.
@@ -831,6 +832,10 @@ def fit_sequential(
831832
Glob pattern to filter files in *data_dir*.
832833
extract_diffrn : Callable | None, default=None
833834
User callback: ``f(file_path) → {diffrn_field: value}``.
835+
reverse : bool, default=False
836+
When ``True``, process data files in reverse order. Useful when
837+
starting values are better matched to the last file (e.g.
838+
highest-temperature dataset in a cooling scan).
834839
"""
835840
if mp.parent_process() is not None:
836841
return
@@ -850,6 +855,8 @@ def fit_sequential(
850855
)
851856

852857
remaining = [p for p in data_paths if p not in already_fitted]
858+
if reverse:
859+
remaining.reverse()
853860
if not remaining:
854861
if verb is not VerbosityEnum.SILENT:
855862
print('✅ All files already fitted. Nothing to do.')

0 commit comments

Comments
 (0)