-
Notifications
You must be signed in to change notification settings - Fork 125
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
Add Output SpinState to SampleLog in PolarizationCorrectionFredrikze Algorithm #38447
base: main
Are you sure you want to change the base?
Add Output SpinState to SampleLog in PolarizationCorrectionFredrikze Algorithm #38447
Conversation
43e7234
to
ac010a2
Compare
be89651
to
499ef76
Compare
… Algorithm - added function to add spinstate to polarizationcorrection fredrikze algorithm - modified mapoutputworkspacetospinstate to add outspinstate to samplelog if requested - updated unit tests to check that the order of output workspaces matches the order of specified output spinstates in the samplelog - updated documentation
499ef76
to
7b0178c
Compare
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.
Thanks for adding this feature to the correction algorithm. I have tested it with the example scripts and can confirm that the spin_state_ORSO
log is correctly displayed when the AddSpinStateToLog
is checked to true.
Thanks also for adding an extensive test coverage, I have added a few suggestions to improve readability of the tests, and I'm not sure whether we should separate the log checking for complete different tests instead of appending them to existing ones, but for the time being, see if you can work on these suggestions.
Framework/Algorithms/test/PolarizationCorrectionFredrikzeTest.h
Outdated
Show resolved
Hide resolved
Framework/Algorithms/test/PolarizationCorrectionFredrikzeTest.h
Outdated
Show resolved
Hide resolved
Framework/Algorithms/test/PolarizationCorrectionFredrikzeTest.h
Outdated
Show resolved
Hide resolved
Framework/Algorithms/test/PolarizationCorrectionFredrikzeTest.h
Outdated
Show resolved
Hide resolved
Framework/Algorithms/test/PolarizationCorrectionFredrikzeTest.h
Outdated
Show resolved
Hide resolved
Framework/Algorithms/test/PolarizationCorrectionFredrikzeTest.h
Outdated
Show resolved
Hide resolved
Framework/Algorithms/test/PolarizationCorrectionFredrikzeTest.h
Outdated
Show resolved
Hide resolved
- remove redundant unit tests - limited the use of hardcoded strings especially for strings used in multiple test functions
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.
Few more small changes
|
||
static const int PA_GROUP_SIZE = 4; | ||
static const int PNR_GROUP_SIZE = 2; |
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.
static const int PA_GROUP_SIZE = 4; | |
static const int PNR_GROUP_SIZE = 2; | |
constexpr int PA_GROUP_SIZE = 4; | |
constexpr int PNR_GROUP_SIZE = 2; |
for (size_t orderIdx = 0; orderIdx < spinStateOrders.size(); ++orderIdx) { | ||
alg->setProperty("InputSpinStates", spinStateOrders[orderIdx]); | ||
alg->setProperty("OutputSpinStates", spinStateOrders[orderIdx]); | ||
alg->setProperty("AddSpinStateToLog", true); |
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.
alg->setProperty("AddSpinStateToLog", true); |
for (size_t orderIdx = 0; orderIdx < spinStateOrders.size(); ++orderIdx) { | ||
alg->setProperty("InputSpinStates", spinStateOrders[orderIdx]); | ||
alg->setProperty("OutputSpinStates", spinStateOrders[orderIdx]); | ||
alg->setProperty("AddSpinStateToLog", true); |
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.
alg->setProperty("AddSpinStateToLog", true); |
@@ -305,20 +327,38 @@ class PolarizationCorrectionFredrikzeTest : public CxxTest::TestSuite { | |||
alg->execute(), std::invalid_argument &); | |||
} | |||
|
|||
// Test various combinations of spin state orders | |||
void test_various_spin_state_orders_for_PA() { | |||
void test_valid_spin_state_order_for_PA() { | |||
auto groupWS = createGroupWorkspace(4, 4, 1, 1); | |||
auto alg = initializeAlgorithm(groupWS, "PA", "1,0,0,0"); | |||
|
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.
alg->setProperty("AddSpinStateToLog", true); | |
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.
Hi Yusuf, just to clarify following our conversation, Adrian is suggesting here that you would have the following:
void test_valid_spin_state_order_for_PA() {
auto groupWS = createGroupWorkspace(4, 4, 1, 1);
auto alg = initializeAlgorithm(groupWS, "PA", "1,0,0,0");
alg->setProperty("AddSpinStateToLog", true);
This way we're setting the AddSpinStateToLog
property to true
, which this test requires, but we're doing it outside the for loop that we have later in the test. This approach should be more efficient because this property will have the same value for every iteration of the loop, so we don't need to keep setting it each time.
As we discussed, you could potentially add something to initializeAlgorithm
to optionally set this property when required. However I think most of the tests in this class do not need to set this property, so it seems fine to leave it to be set separately. If you prefer to move it into initializeAlgorithm
, though, then that would also be fine I think.
|
||
void test_valid_spin_state_order_for_PNR() { | ||
auto groupWS = createGroupWorkspace(2, 4, 1, 1); | ||
auto eff = makeEfficiencies(create1DWorkspace(4, 1, 1), "1,0,0,0", "1,0,0,0"); |
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.
auto eff = makeEfficiencies(create1DWorkspace(4, 1, 1), "1,0,0,0", "1,0,0,0"); |
auto groupWS = createGroupWorkspace(2, 4, 1, 1); | ||
auto eff = makeEfficiencies(create1DWorkspace(4, 1, 1), "1,0,0,0", "1,0,0,0"); | ||
auto alg = initializeAlgorithm(groupWS, "PNR", "1,0,0,0"); | ||
|
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.
alg->setProperty("AddSpinStateToLog", true); | |
Description of work
Fixes #38265
To test:
Test for PA
spin_state_ORSO
.Check that the sample log of each child workspace in the "with_log" group does contain an entry with the name
spin_state_ORSO
. The log values should be as follows:with_log_1
workspace has valuepp
with_log_2
workspace has valuepm
with_log_3
workspace has valuemp
with_log_4
workspace has valuemm
when AddSpinStateToLog checkbox is not enabled: Check that the sample log of each child workspace does not contain an entry with the name
spin_state_ORSO
.when addSpinStateToLog checkbox is enabled: Check that the sample log of each child workspace in the "with_log" group does contain an entry with the name
spin_state_ORSO
. The log values should be as follows:with_log_1
workspace has valuepp
with_log_2
workspace has valuepm
with_log_3
workspace has valuemp
with_log_4
workspace has valuemm
Test for PNR
spin_state_ORSO
.Check that the sample log of each child workspace in the "with_log" group does contain an entry with the name
spin_state_ORSO
. The log values should be as follows:with_log_1
workspace has valuepo
with_log_2
workspace has valuemo
when AddSpinStateToLog checkbox is not enabled: Check that the sample log of each child workspace does not contain an entry with the name
spin_state_ORSO
.when addSpinStateToLog checkbox is enabled: Check that the sample log of each child workspace in the "with_log" group does contain an entry with the name
spin_state_ORSO
. The log values should be as follows:with_log_1
workspace has valuepo
with_log_2
workspace has valuemo