2017-07-05 6 views
2

回帰コードを最下部に実行すると、私はRuntimeWarningのままです。私はそれらを修正する方法がわかりません。それにnanという値があるので、attencoefのリストになると思います。助言がありますか?RunTimeWarningエラーをコードから削除するには?

C:\Users\MTM User\Anaconda3\lib\site-packages\scipy\stats\_stats_mstats_common.py:106: RuntimeWarning: invalid value encountered in double_scalars 
    slope = r_num/ssxm 
C:\Users\MTM User\Anaconda3\lib\site-packages\scipy\stats\_stats_mstats_common.py:116: RuntimeWarning: invalid value encountered in sqrt 
    t = r * np.sqrt(df/((1.0 - r + TINY)*(1.0 + r + TINY))) 
C:\Users\MTM User\Anaconda3\lib\site-packages\scipy\stats\_distn_infrastructure.py:879: RuntimeWarning: invalid value encountered in greater 
    return (self.a < x) & (x < self.b) 
C:\Users\MTM User\Anaconda3\lib\site-packages\scipy\stats\_distn_infrastructure.py:879: RuntimeWarning: invalid value encountered in less 
    return (self.a < x) & (x < self.b) 
C:\Users\MTM User\Anaconda3\lib\site-packages\scipy\stats\_distn_infrastructure.py:1818: RuntimeWarning: invalid value encountered in less_equal 
    cond2 = cond0 & (x <= self.a) 
C:\Users\MTM User\Anaconda3\lib\site-packages\scipy\stats\_stats_mstats_common.py:118: RuntimeWarning: invalid value encountered in double_scalars 
    sterrest = np.sqrt((1 - r**2) * ssym/ssxm/df) 

コード:

for depthvalues in split_depth.values(): # only takes the values (separated lists), removes keys 

    # takes into account the number of yows 
    count+=1 

    depthlst = depthvalues 
    depthfirst = depthlst[0] #find my first depth or deepest depth 
    depthlast = depthlst[-1] # find my last depth, or shallowest 

    depthfirst_index = depth.index(depthfirst) #finds the index of my deepest depth for this segment in the filtered lists 
    depthlast_index = depth.index(depthlast) #finds the index of my shallowest depth for this segment in the filtered lists 

    irradlst = irrad[depthfirst_index:depthlast_index+1] 

    irrad_first = irradlst[0] #finds the corresponding irradiance 
    irrad_last = irradlst[-1] 
    irrad_last = float(irrad_last) 

    irradlst = np.array(irradlst).astype(np.float) 
    depthlst = np.array(depthlst).astype(np.float) 

    attencoef = [np.log(i/irrad_last) for i in irradlst] 

    #whenever I use this line of code(below) I get a bunch of errors 
    regress = linregress(attencoef,depthlst) 
+0

'i/irrad_last'はあなたに非常に大きな数字を与えていますか? 'np.log'は' float( 'inf') 'を生成するものでしょうか? –

答えて

4

をあなたがして警告をフィルタリングする必要があります。

import warnings 
warnings.filterwarnings("ignore", category=RuntimeWarning) 

categoryはのタイプです

これらは私が取得していますエラーですあなたが沈黙したいと警告する。

+0

これは警告を抑制しますが、これは通常は最適ではありません。 –

+1

質問のタイトルには何が尋ねられますか...しかし、そうです、なぜなら、最初にランタイムウォーニングが表示されないようにする理由が最初に見つかるのは良い考えです。 – DarkCygnus

関連する問題