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
8def default_filter_warning(w): # pragma: no cover
9 """
10 Filters out warnings.
12 @param w warning
13 @return boolean (True to keep it)
15 Interesting fields: ``w.message``, ``w.category``, ``w.filename``, ``w.lineno``.
16 """
17 if "RemovedInSphinx40Warning" in str(w):
18 return False
20 class UnusedException(Exception):
21 pass
23 with warnings.catch_warnings():
24 warnings.simplefilter("ignore", DeprecationWarning)
25 try:
26 from matplotlib.cbook import MatplotlibDeprecationWarning
27 except ImportError:
28 MatplotlibDeprecationWarning = UnusedException
30 if "ConvergenceWarning" in str(type(w.message)):
31 return False
32 if isinstance(w.message, FutureWarning):
33 return False
34 if isinstance(w.message, RuntimeWarning):
35 if "_bootstrap.py" in w.filename:
36 if "numpy.dtype size changed" in str(w.message):
37 return False
38 if "More than 20 figures have been opened." in str(w.message):
39 return False
40 elif isinstance(w.message, UserWarning):
41 if "matplotlib" in w.filename:
42 if "findfont: Font family" in str(w.message):
43 return False
44 if "pyquickhelper" in w.filename:
45 if "pymyinstall" in str(w.message):
46 return False
47 elif isinstance(w.message, MatplotlibDeprecationWarning):
48 if "basemap" in w.filename:
49 if "The ishold function was deprecated in version 2.0." in str(w.message):
50 return False
51 elif isinstance(w.message, ResourceWarning):
52 if "pyquickhelper" in w.filename:
53 if "Unable to retrieve content from" in str(w):
54 return False
55 elif isinstance(w.message, DeprecationWarning):
56 if w.filename in ('', None):
57 return False
58 if "`np.str`" in str(w):
59 return False
60 if "`np.bool`" in str(w):
61 return False
62 if "RemovedInSphinx40Warning" in str(w):
63 return False
64 if w.filename.endswith("kernelspec.py"):
65 return False
66 if "jupyter_client" in w.filename:
67 return False
68 elif "IPython" in w.filename:
69 if "DisplayFormatter." in str(w.message):
70 return False
71 if "ScriptMagics." in str(w.message):
72 return False
73 if "HistoryManager." in str(w.message):
74 return False
75 if "ProfileDir." in str(w.message):
76 return False
77 if "InteractiveShell." in str(w.message):
78 return False
79 if "on_trait_change" in str(w.message):
80 return False
81 if "PlainTextFormatter." in str(w.message):
82 return False
83 if "Metadata should be set using the .tag()" in str(w.message):
84 return False
85 elif "nbconvert" in w.filename:
86 if "SlidesExporter." in str(w.message):
87 return False
88 if "TemplateExporter." in str(w.message):
89 return False
90 if "HTMLExporter." in str(w.message):
91 return False
92 if "SVG2PDFPreprocessor." in str(w.message):
93 return False
94 if "on_trait_change" in str(w.message):
95 return False
96 if "PresentExporter." in str(w.message):
97 return False
98 if "NbConvertApp." in str(w.message):
99 return False
100 if "RSTExporter." in str(w.message):
101 return False
102 if "PythonExporter." in str(w.message):
103 return False
104 if "LatexExporter." in str(w.message):
105 return False
106 if "metadata should be set using the .tag()" in str(w.message).lower():
107 return False
108 if 'cgi.escape is deprecated, use html.escape instead' in str(w.message):
109 return False
110 elif "jupyter_core" in w.filename:
111 if "JupyterApp." in str(w.message):
112 return False
113 if "metadata should be set using the .tag()" in str(w.message).lower():
114 return False
115 elif "nbextensions.py" in w.filename:
116 if "metadata should be set using the .tag()" in str(w.message).lower():
117 return False
118 elif "docutils" in w.filename:
119 if "'U' mode is deprecated" in str(w.message):
120 return False
121 if "Metadata should be set using the .tag()" in str(w.message):
122 return False
123 elif "sympy" in w.filename:
124 if "inspect.getargspec() is deprecated" in str(w.message):
125 return False
126 elif "_mode_cbc.py" in w.filename:
127 if "will be forbidden in the future" in str(w.message):
128 return False
129 elif "mpl_toolkits" in w.filename:
130 if "The ishold function was deprecated in version 2.0." in str(w.message):
131 return False
132 if "The hold function was deprecated in version 2.0." in str(w.message):
133 return False
134 if "axes.hold is deprecated." in str(w.message):
135 return False
136 elif "_bootstrap.py" in w.filename:
137 if "can't resolve package from __spec__" in str(w.message):
138 return False
139 elif "basemap" in w.filename:
140 if "The ishold function was deprecated in version 2.0." in str(w.message):
141 return False
142 elif "pandas" in w.filename:
143 if "ix is deprecated" in str(w.message):
144 return False
145 elif "sphinx" in w.filename:
146 if "sphinx.util.compat.Directive is deprecated and will be removed" in str(w.message):
147 return False
148 elif "markdown_mistune.py" in w.filename:
149 if "cgi.escape is deprecated, use html.escape instead" in str(w.message):
150 return False
151 elif isinstance(w.message, ImportWarning):
152 if "_bootstrap.py" in w.filename:
153 if "can't resolve package from __spec__" in str(w.message):
154 return False
155 elif w.filename.endswith("_bootstrap_external.py"):
156 return False
157 elif "MatplotlibDeprecationWarning" in str(type(w.message)):
158 if "basemap" in w.filename:
159 return False
160 return True