diff options
author | Rakesh Vasudevan <rakesh.nvasudev@gmail.com> | 2020-03-15 11:14:34 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-15 20:14:34 +0200 |
commit | cd3b44d5f0915245138d44fdb3ee376601e34716 (patch) | |
tree | 3c926b6c280f97ede79436b43e4a2f7d85c675b5 /numpy/__init__.py | |
parent | 5b16107a537c0ebd2e4517c02ecfb9a24f54c827 (diff) | |
download | numpy-cd3b44d5f0915245138d44fdb3ee376601e34716.tar.gz |
MAINT: Test during import to detect bugs with Accelerate(MacOS) LAPACK (#15695)
* TST: Test during import to detect bugs with Accelerate(MacOS) LAPACK
fixes #15647
* Pipeline update for Accelerate(MacOS) testing
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 |