You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
FWIW, in my branch for #1086 this example is also broken, but at a different point. Instantiating the LinearLSQFitter works, but then on the next line (pfit(x, y)) I get:
In [16]: pfit(x, y)
WARNING: The fit may be poorly conditioned
[astropy.modeling.fitting]
ERROR: ValueError: could not broadcast input array from shape (4) into shape (5) [astropy.modeling.fitting]
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-16-919afb17028d> in <module>()
----> 1 pfit(x, y)
/internal/1/root/src/astropy/astropy/astropy/modeling/fitting.py in __call__(self, x, y, z, weights, rcond)
484 warnings.warn("The fit may be poorly conditioned\n",
485 AstropyUserWarning)
--> 486 self.fitparams = lacoef.flatten()
487
488
/internal/1/root/src/astropy/astropy/astropy/modeling/fitting.py in fitparams(self, fps)
148 """
149
--> 150 self._fitparams[:] = fps
151
152 if any(self.fixed) or any(self.tied):
ValueError: could not broadcast input array from shape (4) into shape (5)
So I'll have to take a look at what's going on there.
I've got this example working correctly in my branch now, so I'll update that soon. I actually also changed this example in the documentation, because the expository text mentions as an example fixing the zero-th order term, but then this example--which immediately follows--shows fixing the first order term, which I think is confusing. So I updated the example to fix the 0-th coefficient c0. But the old example still works too.
Now that #1086 is merged this should be fixed. I just ran through the example again to make sure. The only caveat is that there is now a warning "WARNING: The fit may be poorly conditioned
[astropy.modeling.fitting]"
when performing the fit. I don't think that's a problem, but I'm not sure if it will allow the doctest to pass.
Taking a closer look, I think that might be a bug, albeit a small one. If there are any fixed parameters (as there are in that example), then the rank (effective or otherwise) of the input matrix will generally be smaller than the order of the polynomial. This warning doesn't affect the outcome, but it's raised if rank != model.order, basically. And that won't be the case when there are fixed parameters.
Another case when it's raised is when fitting a polynomial with multiple parameter sets, in which case it's also benign. But it could indicate a real problem (as in #1681) so instead of trying to figure out whether it's a real problem, we just raise a warning. In most cases it is not a problem.
This is not a warning from numpy and I don't think doctests should catch it as there are many occasions when warnings are raised.
Activity
embray commentedon Oct 23, 2013
FWIW, in my branch for #1086 this example is also broken, but at a different point. Instantiating the
LinearLSQFitterworks, but then on the next line (pfit(x, y)) I get:So I'll have to take a look at what's going on there.
embray commentedon Oct 24, 2013
I've got this example working correctly in my branch now, so I'll update that soon. I actually also changed this example in the documentation, because the expository text mentions as an example fixing the zero-th order term, but then this example--which immediately follows--shows fixing the first order term, which I think is confusing. So I updated the example to fix the 0-th coefficient c0. But the old example still works too.
Made some more simplifications in the fitting code by also keeping ar…
embray commentedon Oct 25, 2013
Now that #1086 is merged this should be fixed. I just ran through the example again to make sure. The only caveat is that there is now a warning "WARNING: The fit may be poorly conditioned
[astropy.modeling.fitting]"
when performing the fit. I don't think that's a problem, but I'm not sure if it will allow the doctest to pass.
embray commentedon Oct 25, 2013
Taking a closer look, I think that might be a bug, albeit a small one. If there are any fixed parameters (as there are in that example), then the rank (effective or otherwise) of the input matrix will generally be smaller than the order of the polynomial. This warning doesn't affect the outcome, but it's raised if
rank != model.order, basically. And that won't be the case when there are fixed parameters.nden commentedon Oct 25, 2013
I am working on this.
nden commentedon Oct 25, 2013
Another case when it's raised is when fitting a polynomial with multiple parameter sets, in which case it's also benign. But it could indicate a real problem (as in #1681) so instead of trying to figure out whether it's a real problem, we just raise a warning. In most cases it is not a problem.
This is not a warning from
numpyand I don't think doctests should catch it as there are many occasions when warnings are raised.