I am trying to create a fit function in MANTID which requires an attribute. I have followed the online documentation on how to do this, yet when I try to execute the script, it says that an unknown error has occurred, which causes MANTID to shut down.
My code:
class fitefunc(IFunction1D):
def category(self):
return 'Muon'
# Declare Parameters for the KT function
def init(self):
self.declareAttribute("BinWidth", 0.05)
self.declareParameter("Asymmetry", 0.0)
self.declareParameter("Delta", 0.0)
self.declareParameter("Field", 0.0)
self.declareParameter("nu", 0.0)
def setAttributeValue(self, name, value):
if name == "BinWidth":
# Can the be accessed quicker later using self._nloops
self._tau = value
super(fitefunc, self).setAttributeValue(name, value)
....
It is the last line (the part which calls super) which is singled out by MANTID. Commenting this out stops the error.
Edit:
This is the simplest version of the script which produces the error:
from mantid.api import *
import numpy as np
import numpy.fft as ft
import math
from scipy import integrate
class fitefunc(IFunction1D):
def category(self):
return 'Muon'
def init(self):
self.declareAttribute("BinWidth", 0.05)
self.declareParameter("Asymmetry", 0.0)
self.declareParameter("Delta", 0.0)
self.declareParameter("Field", 0.0)
self.declareParameter("nu", 0.0)
def setAttributeValue(self, name, value):
if name == "BinWidth":
# Can the be accessed quicker later using self._nloops
self._tau = value
super(fitefunc, self).setAttributeValue(name, value)
# Define the fit function
def function1D(self, xvals):
return np.ones(xvals.size)
FunctionFactory.subscribe(fitefunc)