File: utils.py

package info (click to toggle)
python-threadpoolctl 2.1.0-1~bpo10%2B1
  • links: PTS, VCS
  • area: main
  • in suites: buster-backports
  • size: 256 kB
  • sloc: python: 905; sh: 127; makefile: 4
file content (38 lines) | stat: -rw-r--r-- 995 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import os
from glob import glob


# Path to shipped openblas for libraries such as numpy or scipy
libopenblas_patterns = []


try:
    # make sure the mkl/blas are loaded for test_threadpool_limits
    import numpy as np
    np.dot(np.ones(1000), np.ones(1000))

    libopenblas_patterns.append(os.path.join(np.__path__[0], ".libs",
                                             "libopenblas*"))
except ImportError:
    pass


try:
    import scipy
    import scipy.linalg  # noqa: F401
    scipy.linalg.svd([[1, 2], [3, 4]])

    libopenblas_patterns.append(os.path.join(scipy.__path__[0], ".libs",
                                             "libopenblas*"))
except ImportError:
    scipy = None

libopenblas_paths = set(path for pattern in libopenblas_patterns
                        for path in glob(pattern))


try:
    from ._openmp_test_helper import check_openmp_num_threads  # noqa: F401
    cython_extensions_compiled = True
except ImportError:
    cython_extensions_compiled = False