|
21 | 21 |
|
22 | 22 | """ |
23 | 23 |
|
24 | | -from numexpr.interpreter import __BLOCK_SIZE1__, MAX_THREADS, use_vml |
| 24 | +from typing import TYPE_CHECKING, Final |
25 | 25 |
|
26 | | -is_cpu_amd_intel = False # DEPRECATION WARNING: WILL BE REMOVED IN FUTURE RELEASE |
| 26 | +if TYPE_CHECKING: |
| 27 | + import unittest |
| 28 | + |
| 29 | +# the `import _ as _` are needed for mypy to understand these are re-exports |
| 30 | + |
| 31 | +from numexpr.interpreter import __BLOCK_SIZE1__ as __BLOCK_SIZE1__ |
| 32 | +from numexpr.interpreter import MAX_THREADS as MAX_THREADS |
| 33 | +from numexpr.interpreter import use_vml as use_vml |
| 34 | + |
| 35 | +is_cpu_amd_intel: Final = False # DEPRECATION WARNING: WILL BE REMOVED IN FUTURE RELEASE |
27 | 36 |
|
28 | 37 | # cpuinfo imports were moved into the test submodule function that calls them |
29 | 38 | # to improve import times. |
30 | 39 |
|
31 | | -from numexpr.expressions import E |
32 | | -from numexpr.necompiler import (NumExpr, disassemble, evaluate, re_evaluate, |
33 | | - validate) |
34 | | -from numexpr.utils import (_init_num_threads, detect_number_of_cores, |
35 | | - detect_number_of_threads, get_num_threads, |
36 | | - get_vml_version, set_num_threads, |
37 | | - set_vml_accuracy_mode, set_vml_num_threads) |
| 40 | +from numexpr.expressions import E as E |
| 41 | +from numexpr.necompiler import NumExpr as NumExpr |
| 42 | +from numexpr.necompiler import disassemble as disassemble |
| 43 | +from numexpr.necompiler import evaluate as evaluate |
| 44 | +from numexpr.necompiler import re_evaluate as re_evaluate |
| 45 | +from numexpr.necompiler import validate as validate |
| 46 | +from numexpr.utils import _init_num_threads |
| 47 | +from numexpr.utils import detect_number_of_cores as detect_number_of_cores |
| 48 | +from numexpr.utils import detect_number_of_threads as detect_number_of_threads |
| 49 | +from numexpr.utils import get_num_threads as get_num_threads |
| 50 | +from numexpr.utils import get_vml_version as get_vml_version |
| 51 | +from numexpr.utils import set_num_threads as set_num_threads |
| 52 | +from numexpr.utils import set_vml_accuracy_mode as set_vml_accuracy_mode |
| 53 | +from numexpr.utils import set_vml_num_threads as set_vml_num_threads |
38 | 54 |
|
39 | 55 | # Detect the number of cores |
40 | | -ncores = detect_number_of_cores() |
| 56 | +ncores: Final = detect_number_of_cores() |
41 | 57 | # Initialize the number of threads to be used |
42 | | -nthreads = _init_num_threads() |
| 58 | +nthreads: Final = _init_num_threads() |
43 | 59 | # The default for VML is 1 thread (see #39) |
44 | 60 | # set_vml_num_threads(1) |
45 | 61 |
|
46 | | -from . import version |
| 62 | +from . import version as version |
47 | 63 |
|
48 | | -__version__ = version.version |
| 64 | +__version__: Final = version.version |
49 | 65 |
|
50 | | -def print_versions(): |
| 66 | +def print_versions() -> None: |
51 | 67 | """Print the versions of software that numexpr relies on.""" |
52 | 68 | try: |
53 | 69 | import numexpr.tests |
54 | | - return numexpr.tests.print_versions() |
| 70 | + return numexpr.tests.print_versions() # type: ignore[no-untyped-call] |
55 | 71 | except ImportError: |
56 | 72 | # To maintain Python 2.6 compatibility we have simple error handling |
57 | 73 | raise ImportError('`numexpr.tests` could not be imported, likely it was excluded from the distribution.') |
58 | 74 |
|
59 | | -def test(verbosity=1): |
| 75 | +def test(verbosity: int = 1) -> "unittest.result.TestResult": |
60 | 76 | """Run all the tests in the test suite.""" |
61 | 77 | try: |
62 | 78 | import numexpr.tests |
63 | | - return numexpr.tests.test(verbosity=verbosity) |
| 79 | + return numexpr.tests.test(verbosity=verbosity) # type: ignore[no-untyped-call] |
64 | 80 | except ImportError: |
65 | 81 | # To maintain Python 2.6 compatibility we have simple error handling |
66 | 82 | raise ImportError('`numexpr.tests` could not be imported, likely it was excluded from the distribution.') |
0 commit comments