File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -194,3 +194,28 @@ def pkgload(*packages, **options):
194
194
from numpy .testing ._private .pytesttester import PytestTester
195
195
test = PytestTester (__name__ )
196
196
del PytestTester
197
+
198
+
199
+ def _sanity_check ():
200
+ """
201
+ Quick sanity checks for common bugs caused by environment.
202
+ There are some cases e.g. with wrong BLAS ABI that cause wrong
203
+ results under specific runtime conditions that are not necessarily
204
+ achieved during test suite runs, and it is useful to catch those early.
205
+
206
+ See https://github.com/numpy/numpy/issues/8577 and other
207
+ similar bug reports.
208
+
209
+ """
210
+ try :
211
+ x = ones (2 , dtype = float32 )
212
+ if not abs (x .dot (x ) - 2.0 ) < 1e-5 :
213
+ raise AssertionError ()
214
+ except AssertionError :
215
+ msg = ("The current Numpy installation ({!r}) fails to "
216
+ "pass simple sanity checks. This can be caused for example "
217
+ "by incorrect BLAS library being linked in." )
218
+ raise RuntimeError (msg .format (__file__ ))
219
+
220
+ _sanity_check ()
221
+ del _sanity_check
You can’t perform that action at this time.
0 commit comments