diff options
Diffstat (limited to 'numpy/__init__.py')
-rw-r--r-- | numpy/__init__.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/numpy/__init__.py b/numpy/__init__.py index ba35224e6..1d8570f71 100644 --- a/numpy/__init__.py +++ b/numpy/__init__.py @@ -254,3 +254,35 @@ else: _sanity_check() del _sanity_check + + def _mac_os_check(): + """ + Quick Sanity check for Mac OS look for accelerate build bugs. + Testing numpy polyfit calls init_dgelsd(LAPACK) + """ + try: + c = array([3., 2., 1.]) + x = linspace(0, 2, 5) + y = polyval(c, x) + _ = polyfit(x, y, 2, cov=True) + except ValueError: + pass + + import sys + if sys.platform == "darwin": + with warnings.catch_warnings(record=True) as w: + _mac_os_check() + # Throw runtime error, if the test failed Check for warning and error_message + error_message = "" + if len(w) > 0: + error_message = "{}: {}".format(w[-1].category.__name__, str(w[-1].message)) + msg = ( + "Polyfit sanity test emitted a warning, most likely due " + "to using a buggy Accelerate backend. " + "If you compiled yourself, " + "see site.cfg.example for information. " + "Otherwise report this to the vendor " + "that provided NumPy.\n{}\n".format( + error_message)) + raise RuntimeError(msg) + del _mac_os_check |