slybro wrote: > I am having trouble using the polyfit function. Here are the > commands: > > import numpy as np > import scipy as sc > > vp = np.array([1.0, 5.0, 10.0, 20.0, 40.0, 60.0, 100.0, 200.0, 400.0, > 760.0]) > > T = np.array([-36.7, -19.6, -11.5, -2.6, 7.6, 15.4, 26.1, 42.2, 60.6, > 80.1]) > > (a,b,c,d) = np.polyfit(vp,T,3) > > and I get the following error message which I don't understand. >
I'm pretty sure this has to do with Sage giving you the sage floating point numbers by default. Your example seems to work if you declare your arrays like: vp = np.array([1.0, 5.0, 10.0, 20.0, 40.0, 60.0, 100.0, 200.0, 400.0,760.0],dtype=float) T = np.array([-36.7, -19.6, -11.5, -2.6, 7.6, 15.4, 26.1, 42.2, 60.6, 80.1],dtype=float) The "dtype" at the end makes sure that the numbers are python floating point numbers, rather than Sage floating point numbers. Thanks, Jason > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > File "/home/notebook/sage_notebook/worksheets/admin/7/code/7.py", > line 7, in <module> > (a,b,c,d) = np.polyfit(vp,T,_sage_const_3 ) > File "/usr/local/sage/local/lib/python2.5/site-packages/ > zope.interface-3.3.0-py2.5-linux-i686.egg/", line 1, in <module> > > File "/usr/local/sage/local/lib/python2.5/site-packages/numpy/lib/ > polynomial.py", line 493, in polyfit > rcond = len(x)*finfo(x.dtype).eps > File "/usr/local/sage/local/lib/python2.5/site-packages/numpy/lib/ > getlimits.py", line 98, in __new__ > raise ValueError, "data type %r not inexact" % (dtype) > ValueError: data type <type 'numpy.object_'> not inexact > > I have checked www.scipy.org with the associated documentation, the > sage help documentation, the numpy docs and it appears that I am using > the function correctly. I'm stumped... I'm interested in developing > an online class using sage for chemical engineering calculations. > Thanks. > > > > --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---