Closed segasai closed 3 years ago
This is fine, but I suggest making mmin
and mmax
immutable properties so that you can't do something like:
cb = Chabrier(mmin=1,mmax=5)
cb.mmin=2
and get confused
(also lognormal_center
and lognormal_width
)
Yes sorry I forgot about this. But TBH, do we actually want to support the changes of mmin, mmax etc ? It looks like it's a constant source of bugs, as it requires updating all the internal variables etc.
Indeed, I'm suggesting we make the attributes immutable (read-only properties) to avoid these bugs.
I think this is going to break some of my code - maybe some of the existing tools within the package - but we should do it the more correct way, which is only setting mmin/mmax at init time.
at present, this PR will break this code, which wasn't super cleverly written:
https://github.com/keflavich/imf/blob/master/imf/imf.py#L510-L516
the fix is to instantiate a new instance of the selected distribution if mmax, mmin are specified, rather than grab a "cached" version.
The reason for the code above was to reduce the overheads in creating a synthetic cluster. I'm not convinced the time savings were ever worth it.
My suggestion is to put a test first that exercises that functionality. I don't like to refactor stuff that doesn't have a test.
I will do that - sorry, haven't had a chance. Bump this if I leave it too long
I'm merging this to continue the refactor work locally
Hi,
It's a simple change avoiding constructing the distr each time in Chabrier.