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

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

""" 

@file 

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

""" 

import warnings 

 

 

def default_filter_warning(w): # pragma: no cover 

""" 

Filters out warnings. 

 

@param w warning 

@return boolean (True to keep it) 

 

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

""" 

class UnusedException(Exception): 

pass 

 

with warnings.catch_warnings(): 

warnings.simplefilter("ignore", DeprecationWarning) 

try: 

from matplotlib.cbook import MatplotlibDeprecationWarning 

except ImportError: 

MatplotlibDeprecationWarning = UnusedException 

 

if isinstance(w.message, RuntimeWarning): 

if "_bootstrap.py" in w.filename: 

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

return False 

elif isinstance(w.message, UserWarning): 

if "matplotlib" in w.filename: 

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

return False 

elif isinstance(w.message, MatplotlibDeprecationWarning): 

if "basemap" in w.filename: 

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

return False 

elif isinstance(w.message, DeprecationWarning): 

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

return False 

if "jupyter_client" in w.filename: 

return False 

if "IPython" in w.filename: 

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

return False 

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

return False 

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

return False 

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

return False 

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

return False 

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

return False 

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

return False 

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

return False 

elif "nbconvert" in w.filename: 

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

return False 

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

return False 

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

return False 

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

return False 

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

return False 

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

return False 

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

return False 

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

return False 

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

return False 

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

return False 

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

return False 

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

return False 

elif "jupyter_core" in w.filename: 

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

return False 

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

return False 

elif "nbextensions.py" in w.filename: 

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

return False 

elif "docutils" in w.filename: 

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

return False 

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

return False 

elif "sympy" in w.filename: 

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

return False 

elif "_mode_cbc.py" in w.filename: 

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

return False 

elif "mpl_toolkits" in w.filename: 

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

return False 

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

return False 

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

return False 

elif "_bootstrap.py" in w.filename: 

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

return False 

elif "basemap" in w.filename: 

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

return False 

elif "pandas" in w.filename: 

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

return False 

elif "sphinx" in w.filename: 

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

return False 

elif "markdown_mistune.py" in w.filename: 

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

return False 

elif isinstance(w.message, ImportWarning): 

if "_bootstrap.py" in w.filename: 

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

return False 

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

return False 

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

if "basemap" in w.filename: 

return False 

return True