MCPcopy Create free account
hub / github.com/numpy/numpy / _sanity_check

Function _sanity_check

numpy/__init__.py:351–372  ·  view source on GitHub ↗

Quick sanity checks for common bugs caused by environment. There are some cases e.g. with wrong BLAS ABI that cause wrong results under specific runtime conditions that are not necessarily achieved during test suite runs, and it is useful to catch those early.

()

Source from the content-addressed store, hash-verified

349 del PytestTester
350
351 def _sanity_check():
352 """
353 Quick sanity checks for common bugs caused by environment.
354 There are some cases e.g. with wrong BLAS ABI that cause wrong
355 results under specific runtime conditions that are not necessarily
356 achieved during test suite runs, and it is useful to catch those early.
357
358 See https://github.com/numpy/numpy/issues/8577 and other
359 similar bug reports.
360
361 """
362 try:
363 x = ones(2, dtype=float32)
364 if not abs(x.dot(x) - float32(2.0)) < 1e-5:
365 raise AssertionError()
366 except AssertionError:
367 msg = ("The current Numpy installation ({!r}) fails to "
368 "pass simple sanity checks. This can be caused for example "
369 "by incorrect BLAS library being linked in, or by mixing "
370 "package managers (pip, conda, apt, ...). Search closed "
371 "numpy issues for similar problems.")
372 raise RuntimeError(msg.format(__file__)) from None
373
374 _sanity_check()
375 del _sanity_check

Callers 1

__init__.pyFile · 0.85

Calls 3

absFunction · 0.85
dotMethod · 0.80
onesFunction · 0.70

Tested by

no test coverage detected