Closed mbirtwell closed 2 years ago
I got a bit nerd sniped by this. What I was originally trying to do didn't work out. But I think this has worked out quite well. It's just about meaningful to have different instances of the same FitModel
class (in the case of Polynomial
), so it feels right for everything to be instance methods on it now.
@hartytp It looks like I accidentally merged this just before pushing the changes for your comments above. Sorry about that. I think the best thing is probably to just merge them in to your branch also. I'll do that now.
@hartytp It looks like I accidentally merged this just before pushing the changes for your comments above. Sorry about that. I think the best thing is probably to just merge them in to your branch also. I'll do that now.
Oh I think I know what happened. I had the wrong upstream configuration on my local branch and I didn't spot that when I pushed. And because it was a valid fast-forward it just went with it. Ooops again sorry. But hopefully this where we were going to end up soon anyway. We're just missing the merge commit.
no problem. Your changes look really good, thanks again for this.
FitModel parameters are now an instance attribute. This allows two modes of using
FitModel
.This first is by overriding
_func
this allows you to have a better typed experience. The FitParameter metadata is attached as annotations to the arguments of_func
and automatically extracted from there.The second mode is to for dynamic parameter sets. The parameters are passed explicitly to the
FitModel
constructor andfunc
is overridden.The renaming utility is re-cast as a FitModel with dynamic parameters and to me at least feels less magic now than it did before because it can do all the work as regular methods called a wrapped
FitModel
object rather than having to do dynamic class creation.In addition to updating the tests to instantiate
FitModel
objects there are a couple of tweaks to the imports to make them work with my tooling.