Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1""" 

2@file 

3@brief Function which filters ou warnings after running the unit test 

4""" 

5import warnings 

6 

7 

8def default_filter_warning(w): # pragma: no cover 

9 """ 

10 Filters out warnings. 

11 

12 @param w warning 

13 @return boolean (True to keep it) 

14 

15 Interesting fields: ``w.message``, ``w.category``, ``w.filename``, ``w.lineno``. 

16 """ 

17 if "RemovedInSphinx40Warning" in str(w): 

18 return False 

19 

20 class UnusedException(Exception): 

21 pass 

22 

23 with warnings.catch_warnings(): 

24 warnings.simplefilter("ignore", DeprecationWarning) 

25 try: 

26 from matplotlib.cbook import MatplotlibDeprecationWarning 

27 except ImportError: 

28 MatplotlibDeprecationWarning = UnusedException 

29 

30 if isinstance(w.message, RuntimeWarning): 

31 if "_bootstrap.py" in w.filename: 

32 if "numpy.dtype size changed" in str(w.message): 

33 return False 

34 if "More than 20 figures have been opened." in str(w.message): 

35 return False 

36 elif isinstance(w.message, UserWarning): 

37 if "matplotlib" in w.filename: 

38 if "findfont: Font family" in str(w.message): 

39 return False 

40 elif isinstance(w.message, MatplotlibDeprecationWarning): 

41 if "basemap" in w.filename: 

42 if "The ishold function was deprecated in version 2.0." in str(w.message): 

43 return False 

44 elif isinstance(w.message, DeprecationWarning): 

45 if "RemovedInSphinx40Warning" in str(w): 

46 return False 

47 if w.filename.endswith("kernelspec.py"): 

48 return False 

49 if "jupyter_client" in w.filename: 

50 return False 

51 if "IPython" in w.filename: 

52 if "DisplayFormatter." in str(w.message): 

53 return False 

54 if "ScriptMagics." in str(w.message): 

55 return False 

56 if "HistoryManager." in str(w.message): 

57 return False 

58 if "ProfileDir." in str(w.message): 

59 return False 

60 if "InteractiveShell." in str(w.message): 

61 return False 

62 if "on_trait_change" in str(w.message): 

63 return False 

64 if "PlainTextFormatter." in str(w.message): 

65 return False 

66 if "Metadata should be set using the .tag()" in str(w.message): 

67 return False 

68 elif "nbconvert" in w.filename: 

69 if "SlidesExporter." in str(w.message): 

70 return False 

71 if "TemplateExporter." in str(w.message): 

72 return False 

73 if "HTMLExporter." in str(w.message): 

74 return False 

75 if "SVG2PDFPreprocessor." in str(w.message): 

76 return False 

77 if "on_trait_change" in str(w.message): 

78 return False 

79 if "PresentExporter." in str(w.message): 

80 return False 

81 if "NbConvertApp." in str(w.message): 

82 return False 

83 if "RSTExporter." in str(w.message): 

84 return False 

85 if "PythonExporter." in str(w.message): 

86 return False 

87 if "LatexExporter." in str(w.message): 

88 return False 

89 if "metadata should be set using the .tag()" in str(w.message).lower(): 

90 return False 

91 if 'cgi.escape is deprecated, use html.escape instead' in str(w.message): 

92 return False 

93 elif "jupyter_core" in w.filename: 

94 if "JupyterApp." in str(w.message): 

95 return False 

96 if "metadata should be set using the .tag()" in str(w.message).lower(): 

97 return False 

98 elif "nbextensions.py" in w.filename: 

99 if "metadata should be set using the .tag()" in str(w.message).lower(): 

100 return False 

101 elif "docutils" in w.filename: 

102 if "'U' mode is deprecated" in str(w.message): 

103 return False 

104 if "Metadata should be set using the .tag()" in str(w.message): 

105 return False 

106 elif "sympy" in w.filename: 

107 if "inspect.getargspec() is deprecated" in str(w.message): 

108 return False 

109 elif "_mode_cbc.py" in w.filename: 

110 if "will be forbidden in the future" in str(w.message): 

111 return False 

112 elif "mpl_toolkits" in w.filename: 

113 if "The ishold function was deprecated in version 2.0." in str(w.message): 

114 return False 

115 if "The hold function was deprecated in version 2.0." in str(w.message): 

116 return False 

117 if "axes.hold is deprecated." in str(w.message): 

118 return False 

119 elif "_bootstrap.py" in w.filename: 

120 if "can't resolve package from __spec__" in str(w.message): 

121 return False 

122 elif "basemap" in w.filename: 

123 if "The ishold function was deprecated in version 2.0." in str(w.message): 

124 return False 

125 elif "pandas" in w.filename: 

126 if "ix is deprecated" in str(w.message): 

127 return False 

128 elif "sphinx" in w.filename: 

129 if "sphinx.util.compat.Directive is deprecated and will be removed" in str(w.message): 

130 return False 

131 elif "markdown_mistune.py" in w.filename: 

132 if "cgi.escape is deprecated, use html.escape instead" in str(w.message): 

133 return False 

134 elif isinstance(w.message, ImportWarning): 

135 if "_bootstrap.py" in w.filename: 

136 if "can't resolve package from __spec__" in str(w.message): 

137 return False 

138 elif w.filename.endswith("_bootstrap_external.py"): 

139 return False 

140 elif "MatplotlibDeprecationWarning" in str(type(w.message)): 

141 if "basemap" in w.filename: 

142 return False 

143 return True