mantid
mantid copied to clipboard
Hard crash when function constraint is invalid
Describe the bug
A user has reported a hard crash in Mantid when the constraint provided for a fitting function is invalid. There is no error message associated with this issue. This seems to be caused by the absence of operator in the constraint.
To Reproduce Run the following script, uncomment the constraint line to observe the crash:
# import mantid algorithms, numpy and matplotlib
from mantid.simpleapi import *
import numpy as np
ws = CreateSampleWorkspace()
yAxis = ws.readY(0)
xAxis = ws.readX(0)
max_height = np.max(yAxis)
max_index = xAxis[0] + (xAxis[1]-xAxis[0])*(np.where(yAxis == max_height))[0][0]
sigma = 100
fit_fun = "name=Gaussian, PeakCentre={0}, Height={1}, Sigma={2}".format(max_index, 0.7*max_height, sigma)
Fit(
Function=fit_fun,
InputWorkspace=ws,
WorkspaceIndex=1,
# Constraints='invalid', # uncomment this line to observe the crash
StartX=float(max_index - 10 * sigma),
EndX=float(max_index + 10 * sigma),
CreateOutput=True,
IgnoreInvalidData=True,
Output='output')
Expected behavior No hard crash, and a meaningful message in case of potential issues.
Screenshots
Platform/Version (please complete the following information):
- OS: [e.g. Windows, RHEL 7, Ubuntu, macOS]
- OS Version:
- Mantid Version [e.g. 6.0.0]
Additional context