Python scipy.arange() Examples
The following are 30
code examples of scipy.arange().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
scipy
, or try the search function
.
Example #1
Source File: test_mldata.py From twitter-stock-recommendation with MIT License | 6 votes |
def test_fetch_one_column(): _urlopen_ref = datasets.mldata.urlopen try: dataname = 'onecol' # create fake data set in cache x = sp.arange(6).reshape(2, 3) datasets.mldata.urlopen = mock_mldata_urlopen({dataname: {'x': x}}) dset = fetch_mldata(dataname, data_home=tmpdir) for n in ["COL_NAMES", "DESCR", "data"]: assert_in(n, dset) assert_not_in("target", dset) assert_equal(dset.data.shape, (2, 3)) assert_array_equal(dset.data, x) # transposing the data array dset = fetch_mldata(dataname, transpose_data=False, data_home=tmpdir) assert_equal(dset.data.shape, (3, 2)) finally: datasets.mldata.urlopen = _urlopen_ref
Example #2
Source File: dataset_navcam.py From DEMUD with Apache License 2.0 | 6 votes |
def extend(self, extracted_features): # This method reads the pkl files in a folder and adds them to the # existing data for processing in the TCData class. (data, labels, feature_string, width, height, winsize, nbins) = extracted_features npixels = width * height xlabel = 'Grayscale intensity' ylabel = 'Probability' xvals = scipy.arange(self.data.shape[0]).reshape(-1,1) self.data = N.concatenate((self.data, data),axis=1) self.width = N.append(self.width, width) self.height = N.append(self.height, height) self.xvals = N.append(self.xvals, xvals) self.labels.extend(labels) self.img_label_split.extend([len(self.labels)]) self.data_split.extend([self.data.shape[1]])
Example #3
Source File: test_from_joel.py From Mathematics-of-Epidemics-on-Networks with MIT License | 6 votes |
def test_SIR_compact_pairwise(self): EoN.EoNError('changing order of arguments') print("testing SIR_compact_pairwise") Sk0 = scipy.arange(100) * 100 I0 = sum(scipy.arange(100)) R0 = 0 SI0 = 1000 SS0 = Sk0.dot(scipy.arange(100)) - SI0 tau = 0.1 gamma = 0.3 t, S, I, R = EoN.SIR_compact_pairwise(Sk0, I0, R0, SI0, SS0, tau, gamma, tmax=5) print("plotting SIR_compact_pairwise") plt.clf() plt.plot(t, S) plt.plot(t, I) plt.plot(t, R) plt.savefig('SIR_compact_pairwise')
Example #4
Source File: test_lobpcg.py From Computable with MIT License | 6 votes |
def compare_solutions(A,B,m): n = A.shape[0] numpy.random.seed(0) V = rand(n,m) X = linalg.orth(V) eigs,vecs = lobpcg(A, X, B=B, tol=1e-5, maxiter=30) eigs.sort() #w,v = symeig(A,B) w,v = eig(A,b=B) w.sort() assert_almost_equal(w[:int(m/2)],eigs[:int(m/2)],decimal=2) #from pylab import plot, show, legend, xlabel, ylabel #plot(arange(0,len(w[:m])),w[:m],'bx',label='Results by symeig') #plot(arange(0,len(eigs)),eigs,'r+',label='Results by lobpcg') #legend() #xlabel(r'Eigenvalue $i$') #ylabel(r'$\lambda_i$') #show()
Example #5
Source File: test_mldata.py From Mastering-Elasticsearch-7.0 with MIT License | 6 votes |
def test_fetch_one_column(tmpdata): _urlopen_ref = datasets.mldata.urlopen try: dataname = 'onecol' # create fake data set in cache x = sp.arange(6).reshape(2, 3) datasets.mldata.urlopen = mock_mldata_urlopen({dataname: {'x': x}}) dset = fetch_mldata(dataname, data_home=tmpdata) for n in ["COL_NAMES", "DESCR", "data"]: assert_in(n, dset) assert_not_in("target", dset) assert_equal(dset.data.shape, (2, 3)) assert_array_equal(dset.data, x) # transposing the data array dset = fetch_mldata(dataname, transpose_data=False, data_home=tmpdata) assert_equal(dset.data.shape, (3, 2)) finally: datasets.mldata.urlopen = _urlopen_ref
Example #6
Source File: plot_recallPrecision.py From breaking_cycles_in_noisy_hierarchies with BSD 3-Clause "New" or "Revised" License | 6 votes |
def _plotFMeasures(fstepsize=.1, stepsize=0.0005, start = 0.0, end = 1.0): """Plots 10 fmeasure Curves into the current canvas.""" p = sc.arange(start, end, stepsize)[1:] for f in sc.arange(0., 1., fstepsize)[1:]: points = [(x, _fmeasureCurve(f, x)) for x in p if 0 < _fmeasureCurve(f, x) <= 1.5] try: xs, ys = zip(*points) curve, = pl.plot(xs, ys, "--", color="gray", linewidth=0.8) # , label=r"$f=%.1f$"%f) # exclude labels, for legend # bad hack: # gets the 10th last datapoint, from that goes a bit to the left, and a bit down datapoint_x_loc = int(len(xs)/2) datapoint_y_loc = int(len(ys)/2) # x_left = 0.05 # y_left = 0.035 x_left = 0.035 y_left = -0.02 pl.annotate(r"$f=%.1f$" % f, xy=(xs[datapoint_x_loc], ys[datapoint_y_loc]), xytext=(xs[datapoint_x_loc] - x_left, ys[datapoint_y_loc] - y_left), size="small", color="gray") except Exception as e: print e #colors = "gcmbbbrrryk" #colors = "yyybbbrrrckgm" # 7 is a prime, so we'll loop over all combinations of colors and markers, when zipping their cycles
Example #7
Source File: petro.py From pychemqt with GNU General Public License v3.0 | 6 votes |
def regresionCurve(self): dlg = Plot(accept=True) x = self.curvaDestilacion.column(0) T = self.curvaDestilacion.column(1, Temperature) dlg.addData(x, T, color="black", ls="None", marker="s", mfc="red") parameters, r2 = curve_Predicted(x, T) xi = arange(0, 1, 0.01) Ti = [_Tb_Predicted(parameters, x_i) for x_i in xi] dlg.addData(xi, Ti, color="black", lw=0.5) # Add equation formula to plot txt = r"$\frac{T-T_{o}}{T_{o}}=\left[\frac{A}{B}\ln\left(\frac{1}{1-x}" txt += r"\right)\right]^{1/B}$" To = Temperature(parameters[0]) txt2 = "\n\n\n$T_o=%s$" % To.str txt2 += "\n$A=%0.4f$" % parameters[1] txt2 += "\n$B=%0.4f$" % parameters[2] txt2 += "\n$r^2=%0.6f$" % r2 dlg.plot.ax.text(0, T[-1], txt, size="14", va="top", ha="left") dlg.plot.ax.text(0, T[-1], txt2, size="10", va="top", ha="left") if dlg.exec_(): self.curveParameters = parameters self.checkStatusCurve()
Example #8
Source File: test_from_joel.py From Mathematics-of-Epidemics-on-Networks with MIT License | 6 votes |
def test_SIS_compact_pairwise(self): print("testing SIS_compact_pairwise") EoN.EoNError('changing order of arguments') Sk0 = scipy.arange(100) * 100 Ik0 = scipy.arange(100) SI0 = Ik0.dot(scipy.arange(100)) SS0 = Sk0.dot(scipy.arange(100)) - SI0 II0 = 0 tau = 0.1 gamma = 0.3 t, S, I = EoN.SIS_compact_pairwise(Sk0, Ik0, SI0, SS0, II0, tau, gamma, tmax=5) print("plotting SIS_compact_pairwise") plt.clf() plt.plot(t, S) plt.plot(t, I) plt.savefig('SIS_compact_pairwise')
Example #9
Source File: c12_19_up_and_out_call.py From Python-for-Finance-Second-Edition with MIT License | 6 votes |
def up_and_out_call(s0,x,T,r,sigma,n_simulation,barrier): n_steps=100. dt=T/n_steps total=0 for j in sp.arange(0, n_simulation): sT=s0 out=False for i in range(0,int(n_steps)): e=sp.random.normal() sT*=sp.exp((r-0.5*sigma*sigma)*dt+sigma*e*sp.sqrt(dt)) if sT>barrier: out=True if out==False: total+=bsCall(s0,x,T,r,sigma) return total/n_simulation #
Example #10
Source File: c14_25_up_and_out_call.py From Python-for-Finance-Second-Edition with MIT License | 6 votes |
def up_and_out_call(s0,x,T,r,sigma,n_simulation,barrier): n_steps=100. dt=T/n_steps total=0 for j in sp.arange(0, n_simulation): sT=s0 out=False for i in range(0,int(n_steps)): e=sp.random.normal() sT*=sp.exp((r-0.5*sigma*sigma)*dt+sigma*e*sp.sqrt(dt)) if sT>barrier: out=True if out==False: total+=bsCall(s0,x,T,r,sigma) return total/n_simulation #
Example #11
Source File: c13_08_KMF_function.py From Python-for-Finance-Second-Edition with MIT License | 6 votes |
def KMV_f(E,D,T,r,sigmaE): n=10000 m=2000 diffOld=1e6 # a very big number for i in sp.arange(1,10): for j in sp.arange(1,m): A=E+D/2+i*D/n sigmaA=0.05+j*(1.0-0.001)/m d1 = (log(A/D)+(r+sigmaA*sigmaA/2.)*T)/(sigmaA*sqrt(T)) d2 = d1-sigmaA*sqrt(T) diff4E= (A*N(d1)-D*exp(-r*T)*N(d2)-E)/A # scale by assets diff4A= A/E*N(d1)*sigmaA-sigmaE # a small number already diffNew=abs(diff4E)+abs(diff4A) if diffNew<diffOld: diffOld=diffNew output=(round(A,2),round(sigmaA,4),round(diffNew,5)) return output #
Example #12
Source File: recipe-576547.py From code with MIT License | 6 votes |
def coupling_optim(y,t): creation=s.zeros(n_bin) destruction=s.zeros(n_bin) #now I try to rewrite this in a more optimized way destruction = -s.dot(s.transpose(kernel),y)*y #much more concise way to express\ #the destruction of k-mers kyn = kernel*y[:,s.newaxis]*y[s.newaxis,:] for k in xrange(n_bin): creation[k] = s.sum(kyn[s.arange(k),k-s.arange(k)-1]) creation=0.5*creation out=creation+destruction return out #Now I go for the optimal optimization of the chi_{i,j,k} coefficients used by Garrick for # dealing with a non-uniform grid.
Example #13
Source File: c9_22_LPSD_f.py From Python-for-Finance-Second-Edition with MIT License | 5 votes |
def LPSD_f(returns, Rf): y=returns[returns-Rf<0] m=len(y) total=0.0 for i in sp.arange(m): total+=(y[i]-Rf)**2 return total/(m-1)
Example #14
Source File: test_from_joel.py From Mathematics-of-Epidemics-on-Networks with MIT License | 5 votes |
def test_SIS_heterogeneous_pairwise(self): print("test_SIS_heterogeneous_pairwise") # graph will be 2 stars: both with 3 "leaves". one of them has central node infected SkSl0 = scipy.array([[0, 0, 0, 0], [0, 0, 0, 3], [0, 0, 0, 0], [0, 3, 0, 0]]) SkIl0 = scipy.array([[0, 0, 0, 0], [0, 0, 0, 3], [0, 0, 0, 0], [0, 0, 0, 0]]) IkIl0 = scipy.zeros((4, 4)) print((SkSl0 + SkIl0).T / (scipy.array([1, 0, 0, 0]) + scipy.arange(4.))) Sk0 = sum((SkSl0 + SkIl0).T / (scipy.array([1, 0, 0, 0]) + scipy.arange(4.))) Ik0 = sum((SkIl0.T + IkIl0).T / (scipy.array([1, 0, 0, 0]) + scipy.arange(4.))) Sk0[0] = 1 print('Sk0', Sk0) print('Ik0', Ik0) tau = 3 gamma = 1 # print(SkIl0, SkSl0 # print(Sk0 # print(Ik0 t, S, I = EoN.SIS_heterogeneous_pairwise(Sk0, Ik0, SkSl0, SkIl0, IkIl0, tau, gamma, tmax=10) plt.clf() plt.plot(t, S, label='pure IC') plt.plot(t, I) G = nx.Graph() G.add_edges_from([(1, 2), (1, 3), (1, 4), (5, 6), (5, 7), (5, 8)]) G.add_node(0) t, S, I = EoN.SIS_heterogeneous_pairwise_from_graph(G, tau, gamma, rho=1. / 9, tmax=10) plt.plot(t, S, '-.', label='uniform') plt.plot(t, I, '-.') plt.legend(loc='upper right') plt.title('starting from different IC') plt.savefig('SIS_heterogeneous_pairwise')
Example #15
Source File: c10_42_binomialCallEuropean.py From Python-for-Finance-Second-Edition with MIT License | 5 votes |
def binomialCall(s,x,T,r,sigma,n=100): deltaT = T /n u = exp(sigma * sqrt(deltaT)) d = 1.0 / u a = exp(r * deltaT) p = (a - d) / (u - d) v = [[0.0 for j in sp.arange(i + 1)] for i in sp.arange(n + 1)] for j in sp.arange(n+1): v[n][j] = max(s * u**j * d**(n - j) - x, 0.0) for i in sp.arange(n-1, -1, -1): for j in sp.arange(i + 1): v[i][j]=exp(-r*deltaT)*(p*v[i+1][j+1]+(1.0-p)*v[i+1][j]) return v[0][0]
Example #16
Source File: c13_07_BIS_interest_simulation.py From Python-for-Finance-Second-Edition with MIT License | 5 votes |
def BIS_f(R,s,n): R=R0 for i in sp.arange(0,n): deltaR=z[i]*s/sp.sqrt(2.) logR=sp.log(R) R=sp.exp(logR+deltaR) output.append(round(R,5)) return output #
Example #17
Source File: util.py From Azimuth with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _qqplot_bar(M=1000000, alphalevel = 0.05,distr = 'log10'): ''' calculate error bars for a QQ-plot -------------------------------------------------------------------- Input: ------------- ---------------------------------------------------- M number of points to compute error bars alphalevel significance level for the error bars (default 0.05) distr space in which the error bars are implemented Note only log10 is implemented (default 'log10') -------------------------------------------------------------------- Returns: ------------- ---------------------------------------------------- betaUp upper error bars betaDown lower error bars theoreticalPvals theoretical P-values under uniform -------------------------------------------------------------------- ''' #assumes 'log10' mRange=10**(sp.arange(sp.log10(0.5),sp.log10(M-0.5)+0.1,0.1));#should be exp or 10**? numPts=len(mRange); betaalphaLevel=sp.zeros(numPts);#down in the plot betaOneMinusalphaLevel=sp.zeros(numPts);#up in the plot betaInvHalf=sp.zeros(numPts); for n in xrange(numPts): m=mRange[n]; #numplessThanThresh=m; betaInvHalf[n]=st.beta.ppf(0.5,m,M-m); betaalphaLevel[n]=st.beta.ppf(alphalevel,m,M-m); betaOneMinusalphaLevel[n]=st.beta.ppf(1-alphalevel,m,M-m); pass betaDown=betaInvHalf-betaalphaLevel; betaUp=betaOneMinusalphaLevel-betaInvHalf; theoreticalPvals=mRange/M; return betaUp, betaDown, theoreticalPvals
Example #18
Source File: util.py From Azimuth with BSD 3-Clause "New" or "Revised" License | 5 votes |
def get_ranks(y, thresh=0.8, prefix="", flip=False, col_name='score'): """ y should be a DataFrame with one column thresh is the threshold at which to call it a knock-down or not col_name = 'score' is only for V2 data flip should be FALSE for both V1 and V2!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! """ if prefix is not None: prefix = prefix + "_" #y_rank = y.apply(ranktrafo) y_rank = y.apply(sp.stats.mstats.rankdata) y_rank /= y_rank.max() if flip: y_rank = 1.0 - y_rank # before this line, 1-labels where associated with low ranks, this flips it around (hence the y_rank > thresh below) # we should NOT flip (V2), see README.txt in ./data y_rank.columns = [prefix + "rank"] y_threshold = (y_rank > thresh)*1 y_threshold.columns = [prefix + "threshold"] # JL: undo the log2 transform (not sure this matters?) y_rank_raw = (2**y).apply(scipy.stats.mstats.rankdata) y_rank_raw /= y_rank_raw.max() if flip: y_rank_raw = 1.0 - y_rank_raw y_rank_raw.columns = [prefix + "rank raw"] assert ~np.any(np.isnan(y_rank)), "found NaN ranks" # divides into quantiles, but not used: # y_quantized = pandas.DataFrame(data=pandas.qcut(y[col_name], 5, labels=np.arange(5.0))) # quantized vector y_quantized = y_threshold.copy() y_quantized.columns = [prefix + "quantized"] return y_rank, y_rank_raw, y_threshold, y_quantized
Example #19
Source File: util.py From Azimuth with BSD 3-Clause "New" or "Revised" License | 5 votes |
def dcg(relevances, rank=20): relevances = np.asarray(relevances)[:rank] n_relevances = len(relevances) if n_relevances == 0: return 0. discounts = np.log2(np.arange(n_relevances) + 2) return np.sum(relevances / discounts)
Example #20
Source File: liblinear.py From AVEC2018 with MIT License | 5 votes |
def csr_to_problem(x, prob): # Extra space for termination node and (possibly) bias term x_space = prob.x_space = scipy.empty((x.nnz+x.shape[0]*2), dtype=feature_node) prob.rowptr = x.indptr.copy() prob.rowptr[1:] += 2*scipy.arange(1,x.shape[0]+1) prob_ind = x_space["index"] prob_val = x_space["value"] prob_ind[:] = -1 if jit_enabled: csr_to_problem_jit(x.shape[0], x.data, x.indices, x.indptr, prob_val, prob_ind, prob.rowptr) else: csr_to_problem_nojit(x.shape[0], x.data, x.indices, x.indptr, prob_val, prob_ind, prob.rowptr)
Example #21
Source File: occutils_geomplate.py From pythonocc-utils with GNU Lesser General Public License v3.0 | 5 votes |
def solve_radius(event=None): display.EraseAll() p1 = gp_Pnt(0, 0, 0) p2 = gp_Pnt(0, 10, 0) p3 = gp_Pnt(0, 10, 10) p4 = gp_Pnt(0, 0, 10) p5 = gp_Pnt(5, 5, 5) poly = make_closed_polygon([p1, p2, p3, p4]) for i in arange(0.1, 3., 0.2).tolist(): rcs = RadiusConstrainedSurface(display, poly, p5, i) # face = rcs.solve() print('Goal: %s radius: %s' % (i, rcs.curr_radius)) time.sleep(0.5)
Example #22
Source File: c9_23_efficient_based_on_sortino_ratio.py From Python-for-Finance-Second-Edition with MIT License | 5 votes |
def LPSD_f(returns, Rf): y=returns[returns-Rf<0] m=len(y) total=0.0 for i in sp.arange(m): total+=(y[i]-Rf)**2 return total/(m-1) # function 3: estimate Sortino
Example #23
Source File: test_from_joel.py From Mathematics-of-Epidemics-on-Networks with MIT License | 5 votes |
def test_SIR_heterogeneous_meanfield(self): print("testing SIR_heterogeneous_meanfield") Sk0 = scipy.arange(100) * 100 Ik0 = scipy.arange(100) Rk0 = 0 * scipy.arange(100) t, S, I, R = EoN.SIR_heterogeneous_meanfield(Sk0, Ik0, Rk0, 0.1, 5, tmax=5) print("plotting SIR_heterogeneous_meanfield") plt.clf() plt.plot(t, S) plt.plot(t, I) plt.plot(t, R) plt.savefig('SIR_heterogeneous_meanfield')
Example #24
Source File: test_from_joel.py From Mathematics-of-Epidemics-on-Networks with MIT License | 5 votes |
def test_SIS_heterogeneous_meanfield(self): print("testing SIS_heterogeneous_meanfield") Sk0 = scipy.arange(100) * 100 Ik0 = scipy.arange(100) t, S, I = EoN.SIS_heterogeneous_meanfield(Sk0, Ik0, 1, 10, tmax=1) print("plotting SIS_heterogeneous_meanfield") plt.clf() plt.plot(t, S) plt.plot(t, I) plt.savefig('SIS_heterogeneous_meanfield')
Example #25
Source File: heatTransfer.py From pychemqt with GNU General Public License v3.0 | 5 votes |
def plot(self, indice): self.diagrama.ax.clear() self.diagrama.ax.set_xlim(0, 1) self.diagrama.ax.set_ylim(0, 1) self.diagrama.ax.set_title(QtWidgets.QApplication.translate("pychemqt", "$\Delta T_{ml}$ Correction Factor", None), size='12') self.diagrama.ax.set_xlabel("$P=\\frac{T_{1o}-T_{1i}}{T_{2i}-T_{1i}}$", size='12') self.diagrama.ax.set_ylabel("F", size='14') flujo = self.flujo[indice][1] # self.mixed.setVisible(flujo=="CrFSMix") kwargs = {} if flujo == "CrFSMix": kwargs["mixed"] = str(self.mixed.currentText()) R = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1., 1.2, 1.4, 1.6, 1.8, 2, 2.5, 3, 4, 6, 8, 10, 15, 20] # R=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1] P = arange(0, 1.01, 0.01) for ri in R: f = [CorrectionFactor(p, ri, flujo, **kwargs) for p in P] self.diagrama.plot(P, f, "k") # fraccionx=P[90]-P[80] # fracciony=f[90]-f[80] # try: # angle=arctan(fracciony/fraccionx)*360/2/pi # except ZeroDivisionError: # angle=90 # self.diagrama.ax.annotate("R=%0.1f" %ri, (P[90], f[90]), rotation=angle, size="medium", horizontalalignment="left", verticalalignment="bottom") self.diagrama.draw() img = image.imread('images/equation/%s.png' % flujo) self.image.set_data(img) self.refixImage()
Example #26
Source File: heatTransfer.py From pychemqt with GNU General Public License v3.0 | 5 votes |
def plot(self, indice): self.diagrama.ax.clear() self.diagrama.ax.set_xlim(0, 6) self.diagrama.ax.set_ylim(0, 1) title = QtWidgets.QApplication.translate( "pychemqt", "Heat Transfer effectiveness") self.diagrama.ax.set_title(title, size='12') self.diagrama.ax.set_xlabel("NTU", size='12') self.diagrama.ax.set_ylabel("ε", size='14') flujo = self.flujo[indice][1] self.mixed.setVisible(flujo == "CrFSMix") kw = {} if flujo == "CrFSMix": kw["mixed"] = str(self.mixed.currentText()) C = [0, 0.2, 0.4, 0.6, 0.8, 1.] NTU = arange(0, 6.1, 0.1) for ci in C: e = [0] for N in NTU[1:]: e.append(efectividad(N, ci, flujo, **kw)) self.diagrama.plot(NTU, e, "k") fraccionx = (NTU[40]-NTU[30])/6 fracciony = (e[40]-e[30]) try: angle = arctan(fracciony/fraccionx)*360/2/pi except ZeroDivisionError: angle = 90 self.diagrama.ax.annotate( "C*=%0.1f" % ci, (NTU[29], e[30]), rotation=angle, size="medium", ha="left", va="bottom") self.diagrama.draw() img = image.imread('images/equation/%s.png' % flujo) self.image.set_data(img) self.refixImage()
Example #27
Source File: psycrometry.py From pychemqt with GNU General Public License v3.0 | 5 votes |
def LineList(name, Preferences): """Return a list with the values of isoline name to plot""" if Preferences.getboolean("Psychr", name+"Custom"): t = [] for i in Preferences.get("Psychr", name+'List').split(','): if i: t.append(float(i)) else: start = Preferences.getfloat("Psychr", name+"Start") end = Preferences.getfloat("Psychr", name+"End") step = Preferences.getfloat("Psychr", name+"Step") t = list(arange(start, end, step)) return t
Example #28
Source File: plots.py From pychemqt with GNU General Public License v3.0 | 5 votes |
def calculo(self): ind1=self.Comp1.currentIndex() ind2=self.Comp2.currentIndex() if ind1!=ind2: zi=arange(0.025, 1., 0.025) id1=self.indices[ind1] id2=self.indices[ind2] x=[0] y=[0] for z in zi: try: fraccion=[0.]*len(self.indices) fraccion[ind1]=z fraccion[ind2]=1-z mez=Mezcla(tipo=3, fraccionMolar=fraccion, caudalMasico=1.) tb=mez.componente[0].Tb corr=Corriente(T=tb, P=101325., mezcla=mez) T=corr.eos._Dew_T() corr=Corriente(T=T, P=101325., mezcla=mez) while corr.Liquido.fraccion[0]==corr.Gas.fraccion[0] and corr.T<corr.mezcla.componente[1].Tb: corr=Corriente(T=corr.T-0.1, P=101325., mezcla=mez) x.append(corr.Liquido.fraccion[0]) y.append(corr.Gas.fraccion[0]) except: pass x.append(1) y.append(1) self.rellenar(x, y)
Example #29
Source File: test_lobpcg.py From Computable with MIT License | 5 votes |
def MikotaPair(n): # Mikota pair acts as a nice test since the eigenvalues # are the squares of the integers n, n=1,2,... x = arange(1,n+1) B = diag(1./x) y = arange(n-1,0,-1) z = arange(2*n-1,0,-2) A = diag(z)-diag(y,-1)-diag(y,1) return A,B
Example #30
Source File: nomo_axis.py From pynomo with GNU General Public License v3.0 | 5 votes |
def find_log_ticks(start, stop): """ finds tick values for linear axis """ if (start < stop): min, max = start, stop else: min, max = stop, start # lists for ticks tick_0_list = [] tick_1_list = [] tick_2_list = [] max_decade = math.ceil(math.log10(max)) min_decade = math.floor(math.log10(min)) start_ax = None stop_ax = None for decade in scipy.arange(min_decade, max_decade + 1, 1): # for number in scipy.concatenate((scipy.arange(1,2,0.2),scipy.arange(2,3,0.5),scipy.arange(3,10,1))): for number in [1, 1.2, 1.4, 1.6, 1.8, 2.0, 2.5, 3, 4, 5, 6, 7, 8, 9]: u = number * 10.0 ** decade if u >= min and u <= max: if start_ax == None: start_ax = number stop_ax = number if number == 1: tick_0_list.append(u) if number in [2, 3, 4, 5, 6, 7, 8, 9]: tick_1_list.append(u) if number in [1.2, 1.4, 1.6, 1.8, 2.5]: tick_2_list.append(u) # print tick_0_list # print tick_1_list # print tick_2_list return tick_0_list, tick_1_list, tick_2_list, start_ax, stop_ax