Skip to content
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

Update Unit Tests in PolarizationEffiency Cor #38458

Merged
merged 6 commits into from
Dec 19, 2024

Conversation

yusufjimoh
Copy link
Contributor

Description of work

  • wrote unit tests to check that wildes method perform well when spinstates is added
  • wrote unit tests to check that fredrik method throws exception when tested with wildes-only properties spinstates and flippers
  • wrote unit tests to check that fredrikze method can take AddSpinStateToLog property
  • refactored unit tests for maintainability

Fixes #38287

To test:

  • review unit tests
  • ensure all unit tests pass

This does not require release notes because it involves updating the unit tests

@yusufjimoh yusufjimoh linked an issue Nov 28, 2024 that may be closed by this pull request
2 tasks
@yusufjimoh yusufjimoh marked this pull request as ready for review December 4, 2024 09:14
@yusufjimoh yusufjimoh added ISIS Team: LSS Issue and pull requests managed by the LSS subteam at ISIS Maintenance Unassigned issues to be addressed in the next maintenance period. Reflectometry Issues and pull requests related to reflectometry labels Dec 4, 2024
@yusufjimoh yusufjimoh added this to the Release 6.12 milestone Dec 4, 2024
@rbauststfc rbauststfc assigned rbauststfc and unassigned rbauststfc Dec 5, 2024
Copy link
Contributor

@rbauststfc rbauststfc left a comment

Choose a reason for hiding this comment

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

The reduction in code duplication is already looking really good. I have a few suggestions for ways that we might be able to continue to build on this. It would also be really good to try and make more use of constants where we can too.

yusufjimoh and others added 3 commits December 12, 2024 13:33
- wrote unit tests to check that wildes method perform well when spinstates is added
- wrote unit tests to check that fredrik method throws exception when tested with wildes-only properties spinstates and flippers
- wrote unit tests to check that fredrikze method can take AddSpinStateToLog property
- refactored unit tests for maintainability
@yusufjimoh yusufjimoh force-pushed the 38287-maintenance-tasks-for-polarizationefficiencycor branch from 4b77f47 to 9aec5e6 Compare December 13, 2024 09:30
Copy link
Contributor

@rbauststfc rbauststfc left a comment

Choose a reason for hiding this comment

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

This is looking much more maintainable than it was, thanks very much for the changes so far! There are a couple of further comments I had.

- created efficiency output workspace method to cater for duplication in createEfficiencyWorkspace
- moved functions from setAlgorithmProperties to createAlgorithm method
Copy link
Contributor

@rbauststfc rbauststfc left a comment

Choose a reason for hiding this comment

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

There are some really significant improvements in this test class now, thanks very much. There are just a couple more things I noticed, but those should be the last bits I think.

}

MatrixWorkspace_sptr createEfficiencyOutputWorkspace(size_t size = 10, double endX = 10) {
auto ws1 = createPointWS(size, 0, endX);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need to pass through the kind parameter from createEfficiencies and use that to determine what type of workspaces to create. It looks like originally we would call createPointWs for points and point-short, but if kind == "histo" then we should be calling createHistoWS.

alg->setProperty("InputWorkspaces", inputs);
alg->execute();
WorkspaceGroup_sptr out = AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>(OUTPUT_GRP_NAME);
checkOutputWorkspaceGroupSize(4);

for (size_t i = 0; i < out->size(); ++i) {
Copy link
Contributor

@rbauststfc rbauststfc Dec 18, 2024

Choose a reason for hiding this comment

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

In test_points and test_points_short we're comparing the output and input workspaces using the CompareWorkspaces algorithm. As the code for setting up and calling this algorithm is duplicated between the two tests, could we pull this into a helper method?

Copy link
Contributor

@rbauststfc rbauststfc left a comment

Choose a reason for hiding this comment

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

This refactor has significantly reduced the code duplication and should make it much easier to maintain and extend the tests in future. All code review comments have been addressed and all tests are passing. Thanks very much @yusufjimoh for all your hard work on this one.

@cailafinn cailafinn self-assigned this Dec 19, 2024
@cailafinn cailafinn merged commit 971bea0 into main Dec 19, 2024
10 checks passed
@cailafinn cailafinn deleted the 38287-maintenance-tasks-for-polarizationefficiencycor branch December 19, 2024 15:31
peterfpeterson pushed a commit to peterfpeterson/mantid that referenced this pull request Jan 17, 2025
This is a squashed version of mantidproject#38458

Update Unit Tests in PolarizationEffiency Cor
- wrote unit tests to check that wildes method perform well when spinstates is added
- wrote unit tests to check that fredrik method throws exception when tested with wildes-only properties spinstates and flippers
- wrote unit tests to check that fredrikze method can take AddSpinStateToLog property
- refactored unit tests for maintainability

updated hardcoded strings to use private variables

refactored unit tests to reduce redudancies

Simplify Tests based on code review suggestions
- created efficiency output workspace method to cater for duplication in createEfficiencyWorkspace
- moved functions from setAlgorithmProperties to createAlgorithm method

remove duplication in test_point methods

refactor createEfficiencyOutputWorkspace method
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ISIS Team: LSS Issue and pull requests managed by the LSS subteam at ISIS Maintenance Unassigned issues to be addressed in the next maintenance period. Reflectometry Issues and pull requests related to reflectometry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Maintenance tasks for PolarizationEfficiencyCor
3 participants