pyimfit icon indicating copy to clipboard operation
pyimfit copied to clipboard

Issue with fitting >=3 components: bug in description.py?

Open zychen-astro opened this issue 1 year ago • 1 comments

Hello Peter,

In descriptions.py:

def functionSetIndices(self): """ Get the indices in the full parameters list corresponding to the starts of individual function sets/blocks. Returns ------- indices : list of int """ indices = [0] for i in range(self.nFunctionSets - 1): functionsThisSet = self._functionSets[i].functionList() indices.append(len(functionsThisSet)) return indices

In each iteration it appends len(functionsThisSet) to list indices. So if there are >=3 function sets, with with len(functionsThisSet)=1, the indices will be [0,1,1,...], which does not seem to be correct. This leads the additional components not to be fitted, and sometimes also significantly impact the results for the first two components.

Previously, I modified the relevant code to be: indices.append(indices[-1]+len(functionsThisSet)) and found it working. This issue still exists in v1.0.

Could you please confirm this?

Thank you, Zuyi

zychen-astro avatar Sep 09 '24 22:09 zychen-astro

Hi Zuyi,

Thanks for bringing this to my attention -- I'll take a look and get back to you as soon as possible.

perwin avatar Sep 10 '24 11:09 perwin

Hi Zuyi,

My apologies for not getting back to you on this. I've gone ahead and implemented your fix (and added a unit test for it), and am working on generating an updated version to include it.

Thanks again for noticing this, and for suggesting the fix!

perwin avatar Sep 17 '24 12:09 perwin

Latest release (v1.0.2, propagated to PyPI and conda) should fix this -- if you can, test it and let me know if it works for you.

perwin avatar Sep 17 '24 22:09 perwin

Hi Peter, thank you for the fix. I have update to v1.0.2 and verified that it works!

zychen-astro avatar Sep 17 '24 23:09 zychen-astro