-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow Determination of Workspace Order from Output of PolarizationCorrectionWildes #37643
Allow Determination of Workspace Order from Output of PolarizationCorrectionWildes #37643
Conversation
return c * static_cast<double>(wsIndex + 1); | ||
}, | ||
[&](size_t wsIndex, double c) { | ||
if (pols[wsIndex] == "_++") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code is well-structured, with a clear structure and effective use of lambda functions, which greatly enhance readability. The overall implementation is commendable and aligns with good coding practices.
One minor consideration might be to refactor the repeated if-else blocks into a dedicated function, possibly leveraging an std::unordered_map. This adjustment could reduce redundancy, and make it easier to manage the polarization strings if they need to be modified in the future.
Just a small thought that might be worth exploring:
size_t getPolIndex(const std::string &pol) {
static const std::unordered_map<std::string, size_t> polMap = {
{"_++", 0}, {"_+-", 1}, {"_-+", 2}, {"_--", 3}
};
auto it = polMap.find(pol);
if (it != polMap.end()) {
return it->second;
} else {
throw std::invalid_argument("Unknown polarization string: " + pol);
}
}
names.emplace_back(baseName + "_" + spinState); | ||
API::AnalysisDataService::Instance().addOrReplace(names.back(), ws); | ||
} else { | ||
auto const &i = PolarizationCorrectionsHelpers::indexOfWorkspaceForSpinState(spinStateOrder, spinState); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I encountered a build issue on line 559 that seems to stem from a type mismatch in the call to indexOfWorkspaceForSpinState
. The function is expecting a const std::vector<std::string>&
as its first argument, but it appears that a std::string
is being passed instead
I've noticed both |
No, not functionally. This is the I'll have a second look over the changes and make sure they're being consistent with the file. |
That's interesting to know, Thanks for the explanation. |
There are a few different ways to represent the spin states of your flipper configurations (usually in inputs) and spin states (usually in outputs). Most notably between Wildes' method (+/-) and Fredrikze' method (p/a). The change allows the spin state validator to be initialised with any character to represent the on/off state of flippers or the parallel/antiparallel state of outputs. RE mantidproject#35067
The way that the index finder helper works was changed in another PR. This accounts for that by handling the optional. The optional currently throws an error if it does not return an index, this is not testable as the validation currently prevents providing the spin states in such a way that this would be reached. But is implemented to result in a helpful error rather than a segfault should code changes result in problematic spin state strings getting through. RE mantidproject#35067
RE mantidproject#35067 Co-authored-by: Yusuf Jimoh <[email protected]>
338435d
to
7de1a34
Compare
The build issues have been resolved. I tested the code with and without the new spin states configuration, and it functions well in both scenarios for the PolarizationCorrectionWildes and PolarizationEfficiencyCor algorithms, respectively. The output workspace group was returned in the correct order. The tests added for the new spin states functionality are thorough.
Everything appears to be in order. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I happened to notice that lines 559 and 132 might still be using auto const. not certain if that's intentional
Wildes file uses const west... *grumble* RE mantidproject#35067
7de1a34
to
7557939
Compare
Good catch on 559. 132 matches the rest of the file. |
Thanks for clarifying |
Tests have now passed so reviewing can continue on this one. |
All checks have been completed, and all tests are passing. Pull request approved |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look really good and thanks very much for putting in the effort to make the spin state validator more generic, that will be extremely helpful for future work!
I noticed one or two minor things that I thought might be worth mentioning, although not all necessarily need changing if they were deliberate choices so feel free to go with your preference on those.
I can't seem to see any release notes on this PR, though, so it would be good to add some before merging this in.
Framework/Algorithms/inc/MantidAlgorithms/PolarizationCorrections/SpinStateValidator.h
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I realise as this is at gatekeeper stage I'd better set to request changes to prevent merging before we have a release note.
👋 Hi, @cailafinn, Conflicts have been detected against the base branch. Please rebase your branch against the base branch. |
The flipper configuration constants have been moved from the SpinValidator to the PolarizationCorrectionsHelpers file, so new algorithm PolarizationEfficienciesWildes needs to be updated to use these.
Changes have been made since the original review
@cailafinn, the changes on this are looking really good, I've tested the changes to the validation and that's all working well. Thanks for adding a release note too. I'm afraid this PR of mine that was merged in yesterday caused some conflicting changes and I thought it seemed a bit unfair for you to have to sort those out when you got back, so I've resolved them, I hope that's OK. @yusufjimoh, would you be happy to do a quick re-review (i.e. look through the code to confirm you're happy with the changes since your last review, but no need to re-do manual testing at this stage)? If you're happy then you can approve the PR as normal and I will gatekeeper it. |
Description of work
Summary of work
Adds a new
SpinStates
property to the algorithm that allows the user to select the order that the spin state (++
,-+
, etc.) workspaces appear in the output WorkspaceGroup.Fixes #35067
Further detail of work
SpinStateValidator
to handle SpinStates (++
) and FlipperConfigurations (00
).To test:
Flippers='00, 11'
and addSpinStates=
--,++,-+,+-`.Reviewer
Please comment on the points listed below (full description).
Your comments will be used as part of the gatekeeper process, so please comment clearly on what you have checked during your review. If changes are made to the PR during the review process then your final comment will be the most important for gatekeepers. In this comment you should make it clear why any earlier review is still valid, or confirm that all requested changes have been addressed.
Code Review
Functional Tests
Does everything look good? Mark the review as Approve. A member of
@mantidproject/gatekeepers
will take care of it.Gatekeeper
If you need to request changes to a PR then please add a comment and set the review status to "Request changes". This will stop the PR from showing up in the list for other gatekeepers.