Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def save_fit(self):
"""Saves fit results to an NXentry"""
self.read_parameters()
group = NXprocess()
group['data'] = self.data
for f in self.functions:
group[f.name] = self.get_model(f)
parameters = NXparameters()
for p in f.parameters:
parameters[p.name] = NXfield(p.value, error=p.stderr,
initial_value=p.init_value,
min=str(p.min), max=str(p.max))
group[f.name].insert(parameters)
if self.fit is not None:
group['program'] = 'lmfit'
group['version'] = lmfit.__version__
group['title'] = 'Fit Results'
group['fit'] = self.get_model()
fit = NXparameters()
fit.nfev = self.fit.result.nfev