如何从代码中删除RunTimeWarning错误?

时间:2017-07-05 18:28:33

标签: python numpy linear-regression compiler-warnings spyder

当我在最底层运行回归代码时,我不断获得using System.Collections; using System.Collections.Generic; using UnityEngine; public class SecretDoor1 : MonoBehaviour { void OnTriggerEnter2D (Collider2D SecretDoorTrig) { if (SecretDoorTrig.gameObject.tag == "Player") { GetComponent<SpriteRenderer> ().enabled = false; } else { GetComponent<SpriteRenderer> ().enabled = true; } } void OnTriggerExit2D (Collider2D SecretDoorTrig) { if (SecretDoorTrig.gameObject.tag == "Player") { GetComponent<SpriteRenderer> ().enabled = true; } else { GetComponent<SpriteRenderer> ().enabled = false; } } } 。我不知道如何修复它们。我相信它可能是RuntimeWarning列表,因为其中包含一些attencoef值。有什么建议?

这些是我得到的错误:

nan

代码:

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)

1 个答案:

答案 0 :(得分:5)

您应该使用以下内容过滤警告:

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

category是您想要沉默的警告类型。