MCPcopy
hub / github.com/numpy/numpy / _sanity_check

Function _sanity_check

numpy/__init__.py:786–807  ·  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

784 del PytestTester
785
786 def _sanity_check():
787 """
788 Quick sanity checks for common bugs caused by environment.
789 There are some cases e.g. with wrong BLAS ABI that cause wrong
790 results under specific runtime conditions that are not necessarily
791 achieved during test suite runs, and it is useful to catch those early.
792
793 See https://github.com/numpy/numpy/issues/8577 and other
794 similar bug reports.
795
796 """
797 try:
798 x = ones(2, dtype=float32)
799 if not abs(x.dot(x) - float32(2.0)) < 1e-5:
800 raise AssertionError
801 except AssertionError:
802 msg = ("The current Numpy installation ({!r}) fails to "
803 "pass simple sanity checks. This can be caused for example "
804 "by incorrect BLAS library being linked in, or by mixing "
805 "package managers (pip, conda, apt, ...). Search closed "
806 "numpy issues for similar problems.")
807 raise RuntimeError(msg.format(__file__)) from None
808
809 _sanity_check()
810 del _sanity_check

Callers 1

__init__.pyFile · 0.85

Calls 2

dotMethod · 0.80
onesFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…