kmnhan / erlabpy

Complete python workflow for Angle-Resolved Photoemission Spectroscopy (ARPES)
https://erlabpy.readthedocs.io
GNU General Public License v3.0
6 stars 7 forks source link

Wrong signature in MultiPeakModel #38

Closed kmnhan closed 6 months ago

kmnhan commented 6 months ago

Description

After a call to make_params, sigma and amplitude which are not real function parameters appear in function signature detected by lmfit.

Expected behavior

Sigma and amplitude should not appear in parameter names, nor appear in the covariance matrix.

Minimal Complete Verifiable Example

import numpy as np

model = MultiPeakModel(npeaks=1, fd=False, convolve=False)

print(model.param_names)
# ['p0_center', 'p0_width', 'p0_height', 'lin_bkg', 'const_bkg']

model.make_params()

print(model.param_names)
# ['p0_center', 'p0_width', 'p0_height', 'lin_bkg', 'const_bkg', 'p0_sigma', 'p0_amplitude']

MVCE confirmation

Additional context

No response

kmnhan commented 6 months ago

This also happens for built-in models so it is not our problem, but strangely it doesn't happen for composite models. Maybe a bug in lmfit

kmnhan commented 6 months ago

On second thought, make_params should be called before anyone fits anything anyways. Should just call it before getting the parameter names in the fitting accessor.