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

PolarizerEfficiency algorithm validation crash #38483

Open
rbauststfc opened this issue Dec 6, 2024 · 0 comments · May be fixed by #38492
Open

PolarizerEfficiency algorithm validation crash #38483

rbauststfc opened this issue Dec 6, 2024 · 0 comments · May be fixed by #38492
Assignees
Labels
Added during Sprint Tasks that were added after initial sprint planning Bug Issues and pull requests that are regressions or would be considered a bug by users (e.g. crashing) ISIS Team: LSS Issue and pull requests managed by the LSS subteam at ISIS Reported By User Issues that were found or highlighted by a user/scientist SANS Issues and pull requests related to SANS
Milestone

Comments

@rbauststfc
Copy link
Contributor

Original reporter: Dirk from the SANS Group at ISIS

Describe the bug

The PolarizerEfficiency algorithm includes some input validation to check that the size of the workspace group matches the number of spin states that have been passed in. If these do not match then we are currently not returning early to prevent the rest of the validation from continuing. This can cause a crash as in the steps that follow we try to look up the workspace in the group that matches the 00 spin state, but this may be at an index that doesn't exist in the workspace group.

To get the crash the algorithm seems to need to be run from the dialog rather than from a script, otherwise you just see the exception (Exception: WorkspaceGroup - index out of range. Requested=3, current size=2) logged in the messages pane.

To Reproduce

To see the exception logged in the messages pane, run:

ws00 = CreateSampleWorkspace('Histogram', Function='User Defined', UserDefinedFunction='name=UserFunction,Formula=0.5*exp(-0.0733*12*x*(1-0.1))',XUnit='Wavelength', xMin='1',XMax='8', BinWidth='1', NumBanks='1', BankPixelWidth='1')
ws01 = CloneWorkspace(ws00)

grp = GroupWorkspaces([ws00,ws01])
eCell = CreateSampleWorkspace('Histogram', Function='User Defined', UserDefinedFunction='name=UserFunction,Formula=(1 + tanh(0.0733 * 12 * x * 0.2))/2',XUnit='Wavelength', xMin='1',XMax='8', BinWidth='1', NumBanks='1', BankPixelWidth='1')

psm = PolarizerEfficiency(grp, eCell, SpinStates="11,10,01,00")

Having done this, you can reproduce the crash by running the PolarizerEfficiency algorithm from the algorithm dialog using the inputs given above.

Expected behavior

We should display a suitable error message and Mantid shouldn't crash.

Platform/Version (please complete the following information):

  • Mantid Version: 6.11 (when algorithm was first added)

Additional context

I think we just need to change this if statement in the validateInputs method:

  if (spinStates.size() != inputWsCount) {
    errorList[PropertyNames::SPIN_STATES] =
        "The number of workspaces in the input WorkspaceGroup (" + std::to_string(inputWsCount) +
        ") does not match the number of spin states provided (" + std::to_string(spinStates.size()) + ").";
  }

to be:

  if (spinStates.size() != inputWsCount) {
    errorList[PropertyNames::SPIN_STATES] =
        "The number of workspaces in the input WorkspaceGroup (" + std::to_string(inputWsCount) +
        ") does not match the number of spin states provided (" + std::to_string(spinStates.size()) + ").";
    return errorList;
  }

And add appropriate test coverage.

@rbauststfc rbauststfc added Bug Issues and pull requests that are regressions or would be considered a bug by users (e.g. crashing) SANS Issues and pull requests related to SANS ISIS Team: LSS Issue and pull requests managed by the LSS subteam at ISIS Reported By User Issues that were found or highlighted by a user/scientist labels Dec 6, 2024
@rbauststfc rbauststfc added this to the Release 6.12 milestone Dec 6, 2024
@rbauststfc rbauststfc moved this to Ready for Development in ISIS Polarised SANS Reduction Dec 6, 2024
@rbauststfc rbauststfc moved this from New to Backlog in ISIS LSS Sprint Planning Dec 6, 2024
@rbauststfc rbauststfc added the Added during Sprint Tasks that were added after initial sprint planning label Dec 6, 2024
@rbauststfc rbauststfc self-assigned this Dec 10, 2024
@rbauststfc rbauststfc moved this from Backlog to In Progress in ISIS LSS Sprint Planning Dec 10, 2024
@rbauststfc rbauststfc moved this from Ready for Development to In Progress in ISIS Polarised SANS Reduction Dec 10, 2024
@rbauststfc rbauststfc moved this from In Progress to Review in ISIS LSS Sprint Planning Dec 10, 2024
@rbauststfc rbauststfc moved this from In Progress to In Developer Review in ISIS Polarised SANS Reduction Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Added during Sprint Tasks that were added after initial sprint planning Bug Issues and pull requests that are regressions or would be considered a bug by users (e.g. crashing) ISIS Team: LSS Issue and pull requests managed by the LSS subteam at ISIS Reported By User Issues that were found or highlighted by a user/scientist SANS Issues and pull requests related to SANS
Projects
Status: Review
Status: In Developer Review
Development

Successfully merging a pull request may close this issue.

1 participant