|
7 | 7 | import sys
|
8 | 8 | import itertools
|
9 | 9 | import traceback
|
10 |
| -import warnings |
| 10 | +import textwrap |
| 11 | +import subprocess |
11 | 12 |
|
12 | 13 | import numpy as np
|
13 | 14 | from numpy import array, single, double, csingle, cdouble, dot, identity
|
@@ -1632,6 +1633,40 @@ def test_xerbla_override():
|
1632 | 1633 | raise SkipTest('Numpy xerbla not linked in.')
|
1633 | 1634 |
|
1634 | 1635 |
|
| 1636 | +def test_sdot_bug_8577(): |
| 1637 | + # Regression test that loading certain other libraries does not |
| 1638 | + # result to wrong results in float32 linear algebra. |
| 1639 | + # |
| 1640 | + # There's a bug gh-8577 on OSX that can trigger this, and perhaps |
| 1641 | + # there are also other situations in which it occurs. |
| 1642 | + # |
| 1643 | + # Do the check in a separate process. |
| 1644 | + |
| 1645 | + bad_libs = ['PyQt5.QtWidgets', 'IPython'] |
| 1646 | + |
| 1647 | + template = textwrap.dedent(""" |
| 1648 | + import sys |
| 1649 | + {before} |
| 1650 | + try: |
| 1651 | + import {bad_lib} |
| 1652 | + except ImportError: |
| 1653 | + sys.exit(0) |
| 1654 | + {after} |
| 1655 | + x = np.ones(2, dtype=np.float32) |
| 1656 | + sys.exit(0 if np.allclose(x.dot(x), 2.0) else 1) |
| 1657 | + """) |
| 1658 | + |
| 1659 | + for bad_lib in bad_libs: |
| 1660 | + code = template.format(before="import numpy as np", after="", |
| 1661 | + bad_lib=bad_lib) |
| 1662 | + subprocess.check_call([sys.executable, "-c", code]) |
| 1663 | + |
| 1664 | + # Swapped import order |
| 1665 | + code = template.format(after="import numpy as np", before="", |
| 1666 | + bad_lib=bad_lib) |
| 1667 | + subprocess.check_call([sys.executable, "-c", code]) |
| 1668 | + |
| 1669 | + |
1635 | 1670 | class TestMultiDot(object):
|
1636 | 1671 |
|
1637 | 1672 | def test_basic_function_with_three_arguments(self):
|
|
0 commit comments