Version 2 of PEARLTransfit algorithm#41373
Conversation
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
📝 WalkthroughWalkthroughThis 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)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (7)
Framework/PythonInterface/plugins/CMakeLists.txtFramework/PythonInterface/plugins/algorithms/PEARLTransfit2.pyFramework/PythonInterface/test/python/plugins/algorithms/CMakeLists.txtFramework/PythonInterface/test/python/plugins/algorithms/PEARLTransfitTest.pyFramework/PythonInterface/test/python/plugins/algorithms/PEARLTransfitV2Test.pydocs/source/algorithms/PEARLTransfit-v2.rstdocs/source/release/v6.16.0/Diffraction/Powder/New_features/39151.rst
Mmm, not very sure. We have a |
0eb2fb7 to
f969537
Compare
- New input/output workflow - Output debug table - get rid of bg guess properties, allow to input in fit table - several refactors to tidy up code, prepare for sequential fitting upgrade - remove constant energy rebinning
f969537 to
86f4f9d
Compare
samtygier-stfc
left a comment
There was a problem hiding this comment.
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.
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
Outputproperty 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
CreateDebugTableis set toTrue.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:
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:
mantid-developersormantid-contributorsteams, add a review commentrerun cito authorize/rerun the CIGatekeeper
As per the gatekeeping guidelines: