Skip to content

Version 2 of PEARLTransfit algorithm#41373

Merged
SilkeSchomann merged 16 commits into
mainfrom
pearltransfit_v2
May 21, 2026
Merged

Version 2 of PEARLTransfit algorithm#41373
SilkeSchomann merged 16 commits into
mainfrom
pearltransfit_v2

Conversation

@adriazalvarez
Copy link
Copy Markdown
Contributor

@adriazalvarez adriazalvarez commented May 8, 2026

Description of work

As outlined in #39151, this new version tries to improve in/out handling, while making other fixes:
In version 2 of this algorithm:
- The Output Workspace and Fit Parameters Table are created as output properties and not directly extracted from the fit, this preserves workspace history.
- The Output property is a string that sets the basename for outputs in the ADS.
- There are no inputs for background parameter estimation, these can be provided in the FitParametersTable.
- There is no rebin in constant energy.
- In non-calibration fits, a debug table with information about sample temperature can be output if CreateDebugTable is set to True.

One proposed feature on #39151 was to add sequential fitting. I've discussed with Richard, and we've agreed since 6.16 is around the corner and the sequential fitting workflow is not really specified yet and would be more workflow breaking than this iteration, this will need further communication with scientist to get a better picture of what's required, or how that fits in a calibration workflow. It should be done as part of a separate issue.

Closes #39151.

To test:

  • You can use the testcode example in the docs to start testing the new features. Try to test different input conditions.
  • Build docs and check everything is ok.

Added release notes


Reviewer

Your comments will be used as part of the gatekeeper process. Comment clearly on what you have checked and tested during your review. Provide an audit trail for any changes requested.

As per the review guidelines:

  • Is the code of an acceptable quality? (Code standards/GUI standards)
  • Has a thorough functional test been performed? Do the changes handle unexpected input/situations?
  • Are appropriately scoped unit and/or system tests provided?
  • Do the release notes conform to the guidelines and describe the changes appropriately?
  • Has the relevant (user and developer) documentation been added/updated?
  • If the PR author isn’t in the mantid-developers or mantid-contributors teams, add a review comment rerun ci to authorize/rerun the CI

Gatekeeper

As per the gatekeeping guidelines:

  • Has a thorough first line review been conducted, including functional testing?
  • At a high-level, is the code quality sufficient?
  • Are the base, milestone and labels correct?

@adriazalvarez adriazalvarez added this to the Release 6.16 milestone May 8, 2026
@adriazalvarez adriazalvarez added the ISIS: Diffraction Issue and pull requests relating to Diffraction at ISIS label May 8, 2026
@adriazalvarez
Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 8, 2026

✅ Actions performed

Full review triggered.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 8, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This pull request implements version 2 of the PEARLTransfit algorithm, a Mantid plugin for extracting sample temperature from neutron transmission resonance data. The implementation adds support for input calibration parameters, output workspace properties, optional debug tables, and explicit temperature calculation with uncertainty propagation via Debye/free-gas relations. Existing version 1 tests are updated with explicit version numbering. A complete test suite for version 2 is added alongside comprehensive documentation and release notes.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 2.17% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: introducing Version 2 of the PEARLTransfit algorithm with improved input/output properties.
Linked Issues check ✅ Passed The PR successfully implements all primary coding requirements from #39151: outputs T/S_Fit as properties, makes S_Fit an input when Calibration=False, adds debug table output, removes Ediv parameter, and removes Bg0Guess properties.
Out of Scope Changes check ✅ Passed All changes are directly aligned with #39151 requirements: algorithm implementation, tests, documentation, and release notes. No out-of-scope modifications detected.
Description check ✅ Passed The PR description clearly relates to the changeset—it outlines Version 2 of PEARLTransfit with specific improvements to input/output handling, removal of parameters, and documentation of behavioral changes matching the added code files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch pearltransfit_v2

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/source/algorithms/PEARLTransfit-v2.rst`:
- Line 27: The hyperlink role currently includes a trailing period inside the
text (:ref:`PEARLTransfit-v1. <algm-PEARLTransfit-v1>`), causing the period to
render as part of the link; edit the string used in the docs so the role text
excludes the period (e.g., change :ref:`PEARLTransfit-v1.
<algm-PEARLTransfit-v1>` to :ref:`PEARLTransfit-v1 <algm-PEARLTransfit-v1>` and
place the period after the role) so the period renders outside the hyperlink.

In `@Framework/PythonInterface/plugins/algorithms/PEARLTransfit2.py`:
- Around line 355-357: The debug_params dict in PEARLTransfit2.py contains a
stray brace in the key "Eff. Temp. (K)}" causing a user-visible typo; update the
key to "Eff. Temp. (K)" in the debug_params assignment (symbol: debug_params)
and also correct the corresponding expected key in the unit test
PEARLTransfitV2Test.py (the mirrored entry around line with "Eff. Temp. (K)}")
so both the implementation and test use "Eff. Temp. (K)".
- Around line 333-339: The computation of fwhm can take sqrt of a negative value
when final_func["GaussianFWHM"]**2 < gauss_fwhm_inst**2; guard this by checking
the radicand before calling sqrt (variables: gauss_fwhm_inst,
final_func["GaussianFWHM"], fwhm, gauss_fwhm, self.gauss_fwhm_ref_temp), and if
the radicand is <= 0 either set fwhm = 0 (or a small epsilon) and log/warn about
the unphysical result, or handle it as an error path so downstream temperature
calculations don’t silently get NaN. Ensure the check is placed just before
computing fwhm and that any chosen fallback is consistently handled downstream.
- Around line 130-131: The ReferenceTemp property is declared with a string
default which makes it a text field; change the declareProperty call for
"ReferenceTemp" to use a numeric default (e.g. 290.0) so it becomes a float
property, and remove any redundant float() casts in the PyExec code that
currently convert the string to float; update references in the class where
"ReferenceTemp" is read (e.g., where PyExec casts it) to assume a float instead
of parsing a string.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: dce60e99-993c-4b64-aaf6-3c759fc8330e

📥 Commits

Reviewing files that changed from the base of the PR and between c090191 and c225047.

📒 Files selected for processing (7)
  • Framework/PythonInterface/plugins/CMakeLists.txt
  • Framework/PythonInterface/plugins/algorithms/PEARLTransfit2.py
  • Framework/PythonInterface/test/python/plugins/algorithms/CMakeLists.txt
  • Framework/PythonInterface/test/python/plugins/algorithms/PEARLTransfitTest.py
  • Framework/PythonInterface/test/python/plugins/algorithms/PEARLTransfitV2Test.py
  • docs/source/algorithms/PEARLTransfit-v2.rst
  • docs/source/release/v6.16.0/Diffraction/Powder/New_features/39151.rst

Comment thread docs/source/algorithms/PEARLTransfit-v2.rst Outdated
Comment thread Framework/PythonInterface/plugins/algorithms/PEARLTransfit2.py Outdated
Comment thread Framework/PythonInterface/plugins/algorithms/PEARLTransfit2.py Outdated
Comment thread Framework/PythonInterface/plugins/algorithms/PEARLTransfit2.py Outdated
@adriazalvarez adriazalvarez marked this pull request as ready for review May 8, 2026 14:11
@samtygier-stfc samtygier-stfc self-assigned this May 12, 2026
Copy link
Copy Markdown
Contributor

@samtygier-stfc samtygier-stfc left a comment

Choose a reason for hiding this comment

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

Looks good. Some nice cleanups compared to the existing code.

A few small comments:

Also, is there anything users need to know when moving to the new version? Does it need migration info?

Comment thread Framework/PythonInterface/plugins/algorithms/PEARLTransfit2.py Outdated
Comment thread Framework/PythonInterface/plugins/algorithms/PEARLTransfit2.py Outdated
Comment thread Framework/PythonInterface/plugins/algorithms/PEARLTransfit2.py Outdated
@adriazalvarez
Copy link
Copy Markdown
Contributor Author

Also, is there anything users need to know when moving to the new version? Does it need migration info?

Mmm, not very sure. We have a deprecated_algorithm decorator for deprecation, but for v2 there is not an equivalent that I know of. If a user tries to put a v1 keyword into the algorithm, the error message indicates that is v2 of the algorithm. Hopefully they will know how to access version 1, so other than the release notes and perhaps communicating it with the pearl scientist? I can ask Richard.
Just in case, I have added a small comment on the summary of version 2 appearing when an algorithm dialog window is created.

Copy link
Copy Markdown
Contributor

@samtygier-stfc samtygier-stfc left a comment

Choose a reason for hiding this comment

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

This looks good. I have tested locally with the script and the GUI. We have had some feedback form PEARL and made some improvements.

There are some larger suggestions, so I'll write up an issue for a future improvement.

@SilkeSchomann SilkeSchomann self-assigned this May 21, 2026
@SilkeSchomann SilkeSchomann merged commit db8ca4c into main May 21, 2026
11 checks passed
@SilkeSchomann SilkeSchomann deleted the pearltransfit_v2 branch May 21, 2026 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ISIS: Diffraction Issue and pull requests relating to Diffraction at ISIS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Version 2 of PEARLTransfit with improvements to in/output properties

3 participants