Repository navigation
Fixes for weights with linear fitter - #10687
Conversation
103f69d to
cb304ef
Compare
|
Thanks, @saimn! I may be wrong, but I think this can be simplified significantly. Let me check... |
|
No, that idea was just a misunderstanding of how you've done it and why -- but could we maybe combine the separate loops for I think it's good to have several tests where the weights aren't all 1, to make sure the results are correct and not just that the code runs. I see you do have one test that uses real weights for a single 2D model and also one for a 1D model set, which covers the main cases of looping & not looping. I wonder about adding some real weights for a 2D model set, to make sure the algebra is still correct in that case, but this is already pretty good and it's great that you're covering all these cases. |
Sure, another pair of eyes would be useful ;).
Indeed. I needed tests to cover quickly all the different kind of inputs, so I basically copied the existing tests and added weights, but using something else than 1 requires to spend more time understanding each test case. We should certainly do that, if the algorithmic part is on the good path. |
jehturner
left a comment
There was a problem hiding this comment.
I haven't actually finished reviewing this but I'll do "finish your review" because I think you won't see my couple of line comments otherwise? How do you want any changes I make? I would think a PR on your PR (like Curtis's) is best, since they'll probably be too complicated for github suggestions. At least this should be easier now we can check further changes against your tests...
|
@jehturner - Yes, a PR on my PR would work 👍 |
Random thought: One of these days, we need to see how many PR to PR we can chain for a single PR. 😄 |
|
Maybe we could try a circular one? |
| def test_linear_fit_2d_model_set_common_weight(self): | ||
| init_model = models.Polynomial2D(degree=2, c1_0=[1, 2], c0_1=[-0.5, 1], | ||
| n_models=2, | ||
| fixed={'c1_0': True, 'c0_1': True}) |
There was a problem hiding this comment.
Just wondering whether there's any special reason for fixing parameters here and in the other test?
|
Is this ready for review? |
|
I think the code is correct now, @nden, |
add97d5 to
8a91e84
Compare
|
@nden @perrygreenfield - This is now ready for review, thanks to @jehturner for addressing the remaining items :) |
pllim
left a comment
There was a problem hiding this comment.
Any plans to address codecov comment about certain LOCs not covered? If it is not covered on purpose, can add # pragma: no cover directive too.
Need another rebase for the change log conflict.
p.s. When this is merge, the weight is off your shoulder! 😉
| assert_allclose(model.c1_0, -0.1, atol=1e-12) | ||
| assert_allclose(model.c0_1, 0.2, atol=1e-12) | ||
|
|
||
| # # The following 2 cases also happen to work, but model set fitting is |
There was a problem hiding this comment.
Not sure if we need to keep those tests, @jehturner ?
There was a problem hiding this comment.
I don't think we particularly need to keep them, but if they're there they could just be uncommented when those fitters support model sets. They do also work now, but I'm not sure it's reasonable to require those cases to continue working as long as the fitters aren't advertised to support model sets (so there's no reason for there to be an extra dimension).
50ed6f3 to
2f3ffc0
Compare
2f3ffc0 to
113f725
Compare
|
We (with @jehturner) are working on integrating this in our fitting code, it works well, and I just found a little issue when weights for one of the models are all 0 and the data is not a masked array. In that case the lapack routine in Numpy will crash with a rather obscure exception ( ping @nden @perrygreenfield - please review when you can :) |
…& y. Only flatten weights completely when common to multiple models. Check consistency of array shapes in _convert_input for all cases: not just the model_set_axis for 1D model sets and the x/y/z shapes for 2D model sets.
Avoid some extra transpositions.
This is to raise a better error than the Numpy one which is not so
clear:
ValueError: On entry to DLASCL parameter number 4 had an illegal value
62774a0 to
0c2c831
Compare
|
@nden - I moved most of the model set tests to |
|
Ping @nden, would be super useful for us to have this in the next bugfix releases (i.e. 4.1.1). |
|
@pllim Is readthedocs failure a known issue, they seem unrelated? Please feel free to merge of so. |
pllim
left a comment
There was a problem hiding this comment.
RTD might be online again but given the diff, it is not critical for merging even if server still down.
| assert_allclose(model.c1_0, -0.1, atol=1e-12) | ||
| assert_allclose(model.c0_1, 0.2, atol=1e-12) | ||
|
|
||
| # # The following 2 cases also happen to work, but model set fitting is |
There was a problem hiding this comment.
I am not sure about this one. Can we use pytest.mark.skip instead?
There was a problem hiding this comment.
I talked with @jehturner and I think it's better to remove them, since this is not a supported feature. If we can keep them in the history, maybe at some point we can find them again if it's useful.
There was a problem hiding this comment.
I pushed a commit to remove these tests, and skipped CI since this is removing only commented lines.
|
RTD warnings are real but unrelated. Merging then. Thanks, everyone! |
Fixes for weights with linear fitter
Fixes for weights with linear fitter
Fixes for weights with linear fitter
Fixes for weights with linear fitter
Fixes for weights with linear fitter
Fix #7035.
I still find the
modelingcode quite confusing between the data axes, model sets, parameters, so I hope that I did it right for all cases (and tests seem to show that it works).