can the sequence of entries in a dictionary be depended on?
Hi, I'm writing a program where i iterate through the entries in a dictionary using a for loop. This for-loop is enclosed by another loop which traverses through a list and checks the relation between each entry in the list and each entry in the dictionary. while I know that dictionaries are 'unordered', I'd like to know if the order of traversal will be the same each time the dictionary is iterated through. like if i have dictionary={key1:"val1", key2:"val2",key3="val3"...} for i in (1,10) for value in dictionary1: print value am i assured that i always get the same sequence of outputs for any two values of i? Thanks. -- http://mail.python.org/mailman/listinfo/python-list
EARN MONEY $1000-25000 PER MONTH TAKE
EARN MONEY $1000-25000 PER MONTH TAKE SIMPLE ONLINE SURVEYS CREATE FREE ACCOUNT OTHER DETAILS LOG ON TO *** http://romanticmoviess.com/ *** -- http://mail.python.org/mailman/listinfo/python-list
Signup and get starts to earn.....
http://123maza.com/46/dos754/ -- http://mail.python.org/mailman/listinfo/python-list
!!!!$$$$only for ladies$$$!!!!
only for ladies$$$ Special site for ladies and women Ladies Secrets A to z of ladies --->>http://www.wix.com/kumarrajlove/ammu just click -- http://mail.python.org/mailman/listinfo/python-list
!!!!$$$$only for ladies$$$!!!!
only for ladies$$$ Special wedsite for ladies and women Ladies Secrets A to z of ladies http://www.wix.com/kumarrajlove/ammu just click -- http://mail.python.org/mailman/listinfo/python-list
Very starnge problem in python
def closset_match(check, arr, itr): id_min = [] for ii in range(itr): id_min_tmp = np.argmin( abs(arr - check) ) id_min.append(id_min_tmp) arr[id_min_tmp] = float('-inf') id_min = np.array(id_min) return id_min def get_match(arr1, arr2, tol, itr): tt = arr2 for ii in range(5,6): id_com = np.where( abs(arr1[ii] - tt) < tol )[0] if np.size(id_com) >= itr: mm = closset_match(arr1[ii], tt[id_com], itr) id_ttt = np.array(id_com)[mm] #print(id_ttt) print(arr2[id_ttt]) tt[id_ttt] = 0.0 -.9 ###float('-inf') print(arr2[id_ttt]) This is the two routines I am using to compare the two float arrays and getting the matching in them up to some tolerance. The very strange thing which is happening here is you see variable arr2 at ID id_ttt before changing the variable tt at the same ID (i.e. id_ttt]) is showing some value but once I am printing its value after assigning tt[id_ttt] = 0.0, arr2[id_ttt] is also showing 0 value however, I have not touched arr2 anywhere as far as changing its values are concerned. Can any one please help me. -- https://mail.python.org/mailman/listinfo/python-list
Python -Simplebool
#x27;, 'mutation_mode' : 'single', 'observe_list' : '', 'keep_state' : 'False', 'missing' : 'random' } # define parameters for each_line in open(ParaFile).readlines(): para_name = each_line.split('=')[0].strip() para_value = each_line.split('=')[1].strip() if para_name in INPUT.keys(): INPUT[para_name] = para_value else: print "Error: Unknown Parameters: %s" % para_name # formalize parameters try: INPUT['rules'] = str(INPUT['rules'].strip()) INPUT['ini_on'] = [node.strip() for node in INPUT['ini_on'].split(',')] INPUT['ini_off'] = [node.strip() for node in INPUT['ini_off'].split(',')] INPUT['turn_on'] = [node.strip() for node in INPUT['turn_on'].split(',')] INPUT['turn_off'] = [node.strip() for node in INPUT['turn_off'].split(',')] INPUT['observe_list'] = [node.strip() for node in INPUT['observe_list'].split(',')] INPUT['mutation_list'] = INPUT['mutation_list'].split(',') INPUT['keep_state'] = INPUT['keep_state'].split(',') INPUT['rounds'] = int(INPUT['rounds']) INPUT['steps'] = int(INPUT['steps']) INPUT['mode'] = str(INPUT['mode']) INPUT['equi_steps']=int(INPUT['equi_steps']) INPUT['mutation_mode']=str(INPUT['mutation_mode']) for empty_keys in INPUT.keys(): if INPUT[empty_keys] == ['']: INPUT[empty_keys] = [] except: print "Error: Invalid input data types!" if INPUT['mode'] not in ['GA', 'Sync','ROA']: print "Wrong simulation method! Using 'GA', 'ROA' or 'Sync'" return INPUT def ChangeInitial(NodesList,States,MutePairs): OutStates=[] for EachState in States: State=list(EachState) for MuteNode,MuteState in MutePairs: State[NodesList.index(MuteNode)]=str(int(MuteState)) OutStates.append(''.join(State)) return OutStates def simu_mutation(INPUT,missing='random'): '''Do simulated mutation expriment of the model''' mut_result={} # to store the mutated result #generate mutation list, only single mutation now mut_list=GenerateCombinations(INPUT) if INPUT['equi_steps'] == 0: for mute_pair in mut_list: mut_result[mute_pair]=[] print 'Now doing mutation',mute_pair model=Model(INPUT,mute_pair) result,final_all=model.IterModel(missing=missing) for out_node in INPUT['observe_list']: mut_result[mute_pair].append('%2.2f'%(sum(result[out_node][-50:])/50)) elif INPUT['equi_steps'] > 0: print 'Now running pre-mutation simulation to reach steady state\n' model=Model(INPUT) AllNodes=model.GetNodes() result_pre,final_pre=model.IterModel(missing) #pre-equilibration run print 'Now running mutation scanning\n' for mute_pair in mut_list: mut_result[mute_pair]=[] print 'Now doing mutation',mute_pair new_model=Model(INPUT,mute_pair) pre_modified=ChangeInitial(AllNodes,final_pre,mute_pair) result,final=new_model.IterModel(missing=missing, InitialList=pre_modified) #actual mutation run for each mutation for out_node in INPUT['observe_list']: mut_result[mute_pair].append(('%2.2f'%(sum(result_pre[out_node][-50:])/50),'%2.2f'%(sum(result[out_node][-50:])/50))) print "Write mutation result to 'mutation_result.csv' " output=open('mutation_result.csv','w') if INPUT['equi_steps'] == 0: #direct mutation output.writelines('MutNodes,MutStates,%s\n'%(','.join(INPUT['observe_list']))) for mute_pair in mut_list: nodes=[] states=[] for node,state in mute_pair: nodes.append(node) states.append(str(state)) output.writelines('%s,%s,%s\n'%('/'.join(nodes),'/'.join(states),','.join(mut_result[mute_pair]))) elif INPUT['equi_steps'] > 0: #mutation with pre-equilibration steps out_list=[] for node in INPUT['observe_list']: out_list.append(node) out_list.append(node+'(mut)') output.writelines('MutNodes,MutStates,%s\n'%(','.join(out_list))) for mute_pair in mut_list: nodes=[] states=[] for node,state in mute_pair: nodes.append(node) states.append(str(state)) result_list=[each_result for each_pair in mut_result[mute_pair] for each_result in each_pair] # collapse results output.writelines('%s,%s,%s\n'%('/'.join(nodes),'/'.join(states),','.join(result_list))) output.close() def GenerateCombinations(INPUT): StrBool={'True':True,'False':False} NodeState=[] Combine=[] for node_list in INPUT['mutation_list']: for node in open(node_list): NodeState.append((node.strip(),StrBool[INPUT['keep_state'][INPUT['mutation_list'].index(node_list)]])) if INPUT['mutation_mode']=='single': for mute_state in NodeState: Combine.append((mute_state,)) return Combine elif INPUT['mutation_mode']=='double': for i in range(len(NodeState)): for j in range(i+1,len(NodeState)): if NodeState[i][0] != NodeState[j][0]: Combine.append((NodeState[i],NodeState[j])) print 'Total %s combinations.'%(len(Combine)) return Combine if __name__ == '__main__': try: para=ParaParser(sys.argv[1]) except: para=ParaParser('mutation.in') simu_mutation(para) After running this file, I got the following error:/home/JPJ/Priya_Ph.D/simple_bool/simplebool/SimpleBool-master/BoolMutation.py in () 383 para=ParaParser(sys.argv[1]) 384 except: --> 385 para=ParaParser('mutation.in') 386 simu_mutation(para) /home/JPJ/Priya_Ph.D/simple_bool/simplebool/SimpleBool-master/BoolMutation.py in ParaParser(ParaFile) 254 } # define parameters 255 --> 256 for each_line in open(ParaFile).readlines(): 257 para_name = each_line.split('=')[0].strip() 258 para_value = each_line.split('=')[1].strip() IOError: [Errno 2] No such file or directory: 'mutation.in' I can't understand, the problem here. Should I specify anything in the Boolmutation.py file. Any help would be appreciated Thank you Regards Priya -- https://mail.python.org/mailman/listinfo/python-list
Levenberg-Marquardt Algorithm
Good morning. I need some suggestion from you if you have encountered this problem ever. I have two 2D arrays one R and another T (which is also a 2D array). Do you know how can I fit T with R in order to find central coordinate x0,y0 for T relative to R??? So the main question is do you know in python how can I fit two 2D arrays to find x0,y0 for one array relative to other. I shall use LM fit in python. But for fitting, I need to have some fittable model but here I am having only two 2D arrays. I know simple cross-correlation would have solved my problem but I have been instructed to do fitting using one array to other. Any comment or suggestion would be helpful. Thanks in advanced. Cheers!! -- https://mail.python.org/mailman/listinfo/python-list
Re: Levenberg-Marquardt Algorithm
On On Wednesday, April 11, 2018 at 12:49:59 PM UTC+5:30, Christian Gollwitzer wrote: > Am 11.04.18 um 08:38 schrieb Priya Singh: > > I have two 2D arrays one R and another T (which is also a 2D array). > > Do you know how can I fit T with R in order to find central > > coordinate x0,y0 for T relative to R??? > > > > So the main question is do you know in python how can I fit two 2D arrays > > to find > > x0,y0 for one array relative to other. I shall use LM fit in python. But > > for fitting, I need to have some fittable model but here I am having only > > two 2D arrays. I know simple cross-correlation would have solved my problem > > but I have been instructed to do fitting using one array to other. > > > The request is nonsense. LM fits an analytical model to data, if you > don't have an analytical model, you need another tool. Cross correlation > is widely used and works well for many such tasks. > > In principle you could also interpolate the one array to new > coordinates, e.g. using scipy.ndimage.interpolation.shift, and minimize > the sum of squared differences. But still LM is the wrong tool here, it > would get trapped in local minima soon, and it uses derivatives. Look > for "image registration" to find typical algorithms used in this context. > > > > Christian I am really sorry, I should rather ask this way. I have two 2D arrays and one array I want to present in cubic spline way. And with this cubic spline representation of one array, I want to fit the other array. But the problem is that in python I have only cubic spline interpolation task, I want to get the form of this representation and then with this form I want to fit another 2D array to get the position of centers of the second array relative to the first array. I have used image registration for the centering which is based on FFT. But I have been instructed to use this method only. So basically can anyone tell me how to get functional for of 2D cubic spline function in python? For 1D I have got many helps but not for 2D. Thanks in advance!! -- https://mail.python.org/mailman/listinfo/python-list
Re: Levenberg-Marquardt Algorithm
On Wednesday, April 11, 2018 at 12:49:59 PM UTC+5:30, Christian Gollwitzer wrote: > Am 11.04.18 um 08:38 schrieb Priya Singh: > > I have two 2D arrays one R and another T (which is also a 2D array). > > Do you know how can I fit T with R in order to find central > > coordinate x0,y0 for T relative to R??? > > > > So the main question is do you know in python how can I fit two 2D arrays > > to find > > x0,y0 for one array relative to other. I shall use LM fit in python. But > > for fitting, I need to have some fittable model but here I am having only > > two 2D arrays. I know simple cross-correlation would have solved my problem > > but I have been instructed to do fitting using one array to other. > > > The request is nonsense. LM fits an analytical model to data, if you > don't have an analytical model, you need another tool. Cross correlation > is widely used and works well for many such tasks. > > In principle you could also interpolate the one array to new > coordinates, e.g. using scipy.ndimage.interpolation.shift, and minimize > the sum of squared differences. But still LM is the wrong tool here, it > would get trapped in local minima soon, and it uses derivatives. Look > for "image registration" to find typical algorithms used in this context. > > > > Christian I am really sorry, I should rather ask this way. I have two 2D arrays and one array I want to present in cubic spline way. And with this cubic spline representation of one array, I want to fit the other array. But the problem is that in python I have only cubic spline interpolation task, I want to get the form of this representation and then with this form I want to fit another 2D array to get the position of centers of the second array relative to the first array. I have used image registration for the centering which is based on FFT. But I have been instructed to use this method only. So basically can anyone tell me how to get functional for of 2D cubic spline function in python? For 1D I have got many helps but not for 2D. Thanks in advance!! -- https://mail.python.org/mailman/listinfo/python-list
Fitting cubic spline on 2D array
Hello all, Can anyone tell me how can I get the functional form of the fitted cubic spline function on to my 2D array? For eg. when we fit the Gaussian on to an array so we have the functional form with the parameters best fitted to my data likewise how can we do for the cubic spline function? Actually, I want to express my array as A = summation_i,j(C_ij * value_ij) Where i and j are the array indices of my 2D array and C_ij should be the functional form of the cubic spline and value_ij is the value of A at that ij index. Can anyone has an idea, it's very urgent. Any help will be of great use to me. Thanks in advance! Regards, Priya -- https://mail.python.org/mailman/listinfo/python-list
python lmfit.minimizer not working
Dear All, I am trying to fit a spectrum using a power law model. I am using lmfit.minimizer. But the problem is that the value of parameter I am getting is same as the initial value. Means minimizer is not working. Here is the part of my code: p = Parameters() p.add('b', value=10) p.add('x_0', value=0.007, vary=False) p.add('a', value=0.2) p.add('tv', value=3.0, min=0.0) def residual(p): v = p.valuesdict() return (f_c_unmask - (v['b'] * (w_c_unmask/ v['x_0'] )**(-v['a']))*(np.exp(-v['tv']*kpa_smc))) mi = minimize(residual, p, method='leastsq') print(fit_report(mi)) The output I am getting: [[Fit Statistics]] # fitting method = leastsq # function evals = 48 # data points = 1304 # variables= 3 chi-square = 232448.935 reduced chi-square = 178.669435 Akaike info crit = 6764.93727 Bayesian info crit = 6780.45685 [[Variables]] b:10.000 +/- 0. (0.00%) (init = 10) x_0: 0.007 (fixed) a:0.2000 +/- 0. (0.00%) (init = 0.2) tv: 4.8215e-12 +/- 0. (0.00%) (init = 3) -- https://mail.python.org/mailman/listinfo/python-list
comp.lang.python
The comp.lang.python.announce newsgroup (or c.l.py.a for short) has been created in early 1998 as a companion newsgroup for comp.lang.python focused on Python-related announcements. ... other items of general interest to the Python community. https://www.gangboard.com/big-data-training/data-science-training -- https://mail.python.org/mailman/listinfo/python-list
2 sample chi-square test
Hi all, I have two spectra with wavelength, flux, and error on flux. I want to find out the variability of these two spectra based on the 2 sample Chi-square test. I am using following code: def compute_chi2_var(file1,file2,zemi,vmin,vmax): w1,f1,e1,c1,vel1 = get_spec_vel(dir_data+file1,zemi) id1 = np.where(np.logical_and(vel1 >= vmin, vel1 < vmax))[0] w2,f2,e2,c2,vel2 = get_spec_vel(dir_data+file2,zemi) id2 = np.where(np.logical_and(vel2 >= vmin, vel2 < vmax))[0] f_int = interp1d(w1[id1], f1[id1]/c1[id1], kind='cubic') e_int = interp1d(w1[id1], e1[id1]/c1[id1], kind='cubic') f_obs,e_obs = f_int(w2[id2]), e_int(w2[id2]) f_exp, e_exp = f2[id2]/c2[id2], e2[id2]/c2[id2] e_net = e_obs**2 + e_exp**2 chi_square = np.sum( (f_obs**2 - f_exp**2)/e_net ) dof = len(f_obs) - 1 pval = 1 - stats.chi2.cdf( chi_square, dof) print('%.10E' % pval) NN = 320 compute_chi2_var(file7[NN],file14[NN],zemi[NN],vmin[NN],vmax[NN]) I am running this code on many files, and I want to grab those pair of spectra where, the p-value of chi-squa is less than 10^(-8), for the change to be unlikely due to a random occurrence. Is my code right concept-wise? Because the chi-squ value is coming out to be very large (positive and negative), such that my p-value is always between 1 and 0 which I know from other's results not correct. Can anyone suggest me is the concept of 2-sample chi-squ applied by me is correct or not? I thank you all in advance. -- https://mail.python.org/mailman/listinfo/python-list
Need help with apack compression code
I need to code for decompressing the file which is compressed using Apack, I am supposed to code it in visual c++, Plz help me finding algorithm compatible to Widows based C or c++. Regards, Priya Kale (Pune) -- http://mail.python.org/mailman/listinfo/python-list
Openings for Release Management
Position: Build and Release Engineer Experience Required: 2 - 7 yrs Qualification: B.E/M.E/M.C.A/B.Tech Skills Required: 1) Working experience in distributed version control system like Mercurial / Bazar / GIT or Subversion 2) Experience in RBuilder 3) Working experience in creating software appliance. 4) Experience in Python 5) Working experience in Ant / Maven 6) Should posses good communication skills: excellent English, both written and spoken is a must. 7) High level of professionalism The Release Engineer function has the following key areas of responsibility: 1) Continuous improvement of Release processes, methodologies and tools to ensure best quality for both product lines: Community Edition and Professional Edition. 2) Track and support the whole Release cycle, coordinating teams involved in the Release processes: engineering, QA, Beta Testers and Community. 3) Keep people informed about status, contents, dates, etc. 4) Support Senior Management to define the guidelines of whole release product strategy. -- http://mail.python.org/mailman/listinfo/python-list
Openings for Release Management
Position: Build and Release Engineer Experience Required: 2 - 7 yrs Qualification: B.E/M.E/M.C.A/B.Tech Skills Required: 1) Working experience in distributed version control system like Mercurial / Bazar / GIT or Subversion 2) Experience in RBuilder 3) Working experience in creating software appliance. 4) Experience in Python 5) Working experience in Ant / Maven 6) Should posses good communication skills: excellent English, both written and spoken is a must. 7) High level of professionalism The Release Engineer function has the following key areas of responsibility: 1) Continuous improvement of Release processes, methodologies and tools to ensure best quality for both product lines: Community Edition and Professional Edition. 2) Track and support the whole Release cycle, coordinating teams involved in the Release processes: engineering, QA, Beta Testers and Community. 3) Keep people informed about status, contents, dates, etc. 4) Support Senior Management to define the guidelines of whole release product strategy. -- http://mail.python.org/mailman/listinfo/python-list
Openings for Release Management
Position: Build and Release Engineer Experience Required: 2 - 7 yrs Qualification: B.E/M.E/M.C.A/B.Tech Skills Required: 1) Working experience in distributed version control system like Mercurial / Bazar / GIT or Subversion 2) Experience in RBuilder 3) Working experience in creating software appliance. 4) Experience in Python 5) Working experience in Ant / Maven 6) Should posses good communication skills: excellent English, both written and spoken is a must. 7) High level of professionalism The Release Engineer function has the following key areas of responsibility: 1) Continuous improvement of Release processes, methodologies and tools to ensure best quality for both product lines: Community Edition and Professional Edition. 2) Track and support the whole Release cycle, coordinating teams involved in the Release processes: engineering, QA, Beta Testers and Community. 3) Keep people informed about status, contents, dates, etc. 4) Support Senior Management to define the guidelines of whole release product strategy. -- http://mail.python.org/mailman/listinfo/python-list