Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/examples/sequential_fit_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,10 @@
plot_variable_names=["a_1"],
plot_result_entry_names=["residual"],
)
sts.set_start_input_file(
"Ni_PDF_20250922-222655_ca8ae7_14K.gr",
input_filename_to_result_filename=lambda input_filename: input_filename.replace( # noqa E501
".gr", "_result.json"
),
)
sts.run(mode="stream")
23 changes: 23 additions & 0 deletions news/runner-test.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* No news added: Added test for ``sequential_cmi_runner``.

**Changed:**

* <news item>

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* <news item>

**Security:**

* <news item>
14 changes: 11 additions & 3 deletions src/pdfbl/sequential/pdfadapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from diffpy.srfit.pdf import PDFGenerator, PDFParser
from diffpy.srfit.structure import constrainAsSpaceGroup
from diffpy.structure.parsers import getParser
from scipy.optimize import minimize
from scipy.optimize import least_squares
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default minimize setting is extremely slow. The time spent is increased from several seconds to several minutes. Switch back to least_squares.



class PDFAdapter:
Expand Down Expand Up @@ -276,11 +276,19 @@ def refine_variables(self, variable_names: list[str]):
variable_names : list of str
The names of the variables to refine.
"""
for vname in variable_names:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check before applying variables.

if vname not in self.recipe._parameters:
raise ValueError(
f"Variable {vname} not found in the recipe. "
"Please choose from the existing variables: "
f"{list(self.recipe._parameters.keys())}"
)
for vname in variable_names:
self.recipe.free(vname)
minimize(
self.recipe.scalarResidual,
least_squares(
self.recipe.residual,
self.recipe.values,
x_scale="jac",
)

def get_variable_names(self) -> list[str]:
Expand Down
Loading
Loading