Latest LQ Deal: Latest LQ Deals
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 12-11-2015, 04:51 AM   #1
LQ Newbie
Registered: Nov 2015
Posts: 4

Rep: Reputation: Disabled
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?

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<root<x_max: roots.add(root[0]) roots=list(roots) #print(np.column_stack((roots,p1(roots),p2(roots)))) def find_nearest(array,value): idx = (np.abs(array-value)).argmin() return array[idx] array = np.array(roots) value = 6.23
Old 12-12-2015, 01:18 PM   #2
LQ Guru
Registered: Jan 2006
Location: Ireland
Distribution: Slackware & Android
Posts: 10,575

Rep: Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172
Have you a good reason not to define it? I thought C likes to have things defined, and gcc is getting strict.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Unsupported checksum type GTKPod and iPod Touch 4G nicolasjengler Linux - Software 2 10-28-2011 05:40 PM
[assembler] Operand type mismatch for 'and' gnashley Programming 8 10-08-2011 05:08 PM
postfix/cleanup[3573]: fatal: unsupported dictionary type: mysql sajumurali Linux - Newbie 6 04-16-2010 01:24 PM
libvirtError: internal error unsupported disk type 'vda' devangjani Linux - Virtualization and Cloud 1 03-19-2010 01:03 PM
postfix problem unsupported dictionary type: mysql build Linux - Server 2 02-22-2010 08:57 PM > Forums > Linux Forums > Linux - Newbie

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

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration