[Numpy-discussion] Question about nump.ma.polyfit
efiring at hawaii.edu
Tue Dec 15 11:34:44 EST 2015
On 2015/12/14 6:39 PM, Samuel Dupree wrote:
> I'm running Python 2.7.11 from the Anaconda distribution (version 2.4.1)
> on a MacBook Pro running Mac OS X version 10.11.2 (El Capitan)
> I'm attempting to use numpy.ma.polyfit to perform a linear least square
> fit on some data I have. I'm running NumPy version 1.10.1. I've observed
> that in executing either numpy.polyfit or numpy.ma.polyfit I get the
> following traceback:
> RankWarning: Polyfit may be poorly conditioned
> warnings.warn(msg, RankWarning)
> Traceback (most recent call last):
> File "ComputeEnergy.py", line 132, in <module>
> coeffs, covar = np.ma.polyfit( xfit, yfit, fit_degree,
> rcond=rcondv, cov=True )
> line 1951, in polyfit
> return np.polyfit(x, y, deg, rcond, full, w, cov)
> line 607, in polyfit
> return c, Vbase * fac
> ValueError: operands could not be broadcast together with shapes (6,6) (0,)
> I've attached a stripped down version of the Python program I'm running.
That is not stripped down very far; it's still not something someone on
the list can run.
> Any suggestions?
Use debugging techniques to figure out what is going on inside your
script. In particular, what are the arguments that polyfit is choking
on? I would run the script in ipython and use the %debug magic to drop
into the debugger when it fails. Then use "up" to move up the stack
until you get to the line calling polyfit, and then use the print
function to print each of the arguments. Chances are, either they will
not be what you expect them to be, or they will, but you will find a
logical inconsistency among them. It looks like you are using Spyder,
presumably with the ipython console, so run your script, then when it
fails type "%debug" in the ipython console window and you will be
dropped into the standard pdb debugger.
> Sam Dupree.
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
More information about the NumPy-Discussion