Skip to content

Move _model_to_fit_params out of ParametricModel#2264

Merged
embray merged 1 commit into
astropy:masterfrom
embray:decouple-fitters
Apr 7, 2014
Merged

Move _model_to_fit_params out of ParametricModel#2264
embray merged 1 commit into
astropy:masterfrom
embray:decouple-fitters

Conversation

@embray

@embray embray commented Mar 31, 2014

Copy link
Copy Markdown
Member

Moved ParametricModel._model_to_fit_params to being a static method in Fitter; this is the first step in separating concerns so that only Fitters are responsible for getting their inputs into the correct format they need. This later might even move into a separate subclass of Fitter since this is particular for getting parameters into the form they need to be in for use with scipy.optimize functions.

This allowed elimitating a lot of code rot in the process.

This did require outright removing a handful of test cases, but those tests would be better handled within the fitter tests anyways--simply marking some parameters as constrained should have no bearing on a model's behavior by itself. In a later PR I will add new tests that replace these ones--that ensure that parameter constraints are handled properly by all included fitters.

This will be the first of several PRs related to further decoupling the implementation of models from how they are used by fitters. Most of these PRs will have some dependency on each other but I will label when that is the case. I want to still split the work up into multiple PRs so it's easier to keep track of individual changes. Several of these changes can also be decoupled from each other if need be.

…n Fitter;

this is the first step in separating concerns so that only Fitters are
responsible for getting their inputs into the correct format they need.

This allowed elimitating a lot of code rot in the process.

This did require outright removing a handful of test cases, but those tests
would be better handled within the fitter tests anyways--simply marking some
parameters as constrained should have no bearing on a *model's* behavior by
itself.
@embray

embray commented Apr 1, 2014

Copy link
Copy Markdown
Member Author

Test failures seem to be unrelated. Is matplotlib no longer supported with Python 3.2?

@cdeil

cdeil commented Apr 4, 2014

Copy link
Copy Markdown
Member

Looks good to me.
@nden Do you have time to have a look?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you get to separating optimizers from statistics, it becomes necessary for fitter_to_model_params to be a function. You may consider making model_to_fit_params a function as well.

(The reason is that LinearLSQFitter and NonLinearLSQFitter (called LevMarLSQFitter in #1914) can't be split into an optimizer and a statistic and so don't inherit from Fitter.)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I agree--this is going to be reworked anyway. Moving around the existing code is just a first step.

@nden

nden commented Apr 7, 2014

Copy link
Copy Markdown
Contributor

@embray Other than that one comment this is good to merge.

@embray embray added this to the v0.4.0 milestone Apr 7, 2014
embray added a commit that referenced this pull request Apr 7, 2014
Move _model_to_fit_params out of ParametricModel
@embray embray merged commit 29d3101 into astropy:master Apr 7, 2014
@embray embray deleted the decouple-fitters branch April 7, 2014 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Affects-dev PRs and issues that do not impact an existing Astropy release modeling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants