Latest LQ Deal: Latest LQ Deals
 LinuxQuestions.org TypeError: unsupported operand type(s) for -: 'set' and 'float'
 Linux - Newbie This Linux forum is for members that are new to Linux. Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

 12-11-2015, 04:51 AM #1 Bobbic LQ Newbie   Registered: Nov 2015 Posts: 4 Rep: TypeError: unsupported operand type(s) for -: 'set' and 'float' Hi Guys, i have a function called fitting. I need it for some simulations. I don't want to write down the whole code because it is to long. The part i give you interpolates two arrays to calculate zero points. The in def find_nearest(array, value) it comes to the error in the subject. i call the function with x = fitting(c_cecora). When i run only the algorithm without define it es def fitting(c_cecora) it runs...but when i call it with x = fitting(c_cecora) it fails. Can you please help me? Code: ```def fitting(c_cecora)... data = np.genfromtxt(vers,delimiter=' ') C_f = data[:,][:,1] xH = data[:,][:,0] x1 = np.linspace(0.0, 50.0, num=430) y1 = np.linspace(0.0, 0.0, num=430) xH = np.array(xH) C_f = np.array(C_f) x1 = np.array(x1) y1 = np.array(y1) p1=interpolate.PiecewisePolynomial(xH,C_f[:,np.newaxis]) p2=interpolate.PiecewisePolynomial(x1,y1[:,np.newaxis]) def pdiff(x): return p1(x)-p2(x) xs=np.r_[xH,x1] xs.sort() x_min=xs.min() x_max=xs.max() x_mid=xs[:-1]+np.diff(xs)/2 roots=set() for val in x_mid: root,infodict,ier,mesg = optimize.fsolve(pdiff,val,full_output=True) # ier==1 indicates a root has been found if ier==1 and x_min
 12-12-2015, 01:18 PM #2 business_kid LQ Guru   Registered: Jan 2006 Location: Ireland Distribution: Slackware & Android Posts: 10,575 Rep: Have you a good reason not to define it? I thought C likes to have things defined, and gcc is getting strict.

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is Off HTML code is Off Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post nicolasjengler Linux - Software 2 10-28-2011 05:40 PM gnashley Programming 8 10-08-2011 05:08 PM sajumurali Linux - Newbie 6 04-16-2010 01:24 PM devangjani Linux - Virtualization and Cloud 1 03-19-2010 01:03 PM build Linux - Server 2 02-22-2010 08:57 PM

LinuxQuestions.org

All times are GMT -5. The time now is 08:35 PM.