Mike: Outstanding! Thank you, I appreciate the help.
Regards, slybro On Sat, Jan 10, 2009 at 10:08 PM, Mike Hansen <[email protected]> wrote: > > Hello, > > On Sat, Jan 10, 2009 at 8:29 PM, slybro <[email protected]> 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) > > You must explicitly make the Numpy array's have dtype float as numpy > does not automatically convert Sage's RealNumber to a float. If you > don't do this, the array's dtype will be "object'. > > sage: 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) > sage: 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) > sage: np.polyfit(vp,T,3) > array([ 1.13148994e-06, -1.49004659e-03, 6.12784745e-01, > -2.13934587e+01]) > > There are other ways to achieve a similar effect such as turning off > the Sage preparser with "preparser(False)" or making Sage's RealNumber > an alias of float ("RealNumber = float"). > > --Mike > > > > --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---
