forked from moble/quaternion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnumba_wrapper.py
49 lines (40 loc) · 1.47 KB
/
numba_wrapper.py
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
39
40
41
42
43
44
45
46
47
48
49
# Copyright (c) 2017, Michael Boyle
# See LICENSE file for details: <https://github.com/moble/quaternion/blob/master/LICENSE>
from __future__ import division, print_function, absolute_import
## Allow the code to function without numba, but discourage it
## strongly.
try:
from numbapro import njit, jit, vectorize, int64, float64, complex128
from numba.utils import IS_PY3
GOT_NUMBA = True
except ImportError:
try:
from numba import njit, jit, vectorize, int64, float64, complex128
from numba.utils import IS_PY3
GOT_NUMBA = True
except ImportError:
import warnings
import sys
warning_text = \
"\n\n" + "!" * 53 + "\n" + \
"Could not import from either numbapro or numba.\n" + \
"This means that the code will run MUCH more slowly.\n" + \
"You probably REALLY want to install numba / numbapro." + \
"\n" + "!" * 53 + "\n"
warnings.warn(warning_text)
def _identity_decorator_outer(*args, **kwargs):
def _identity_decorator_inner(fn):
return fn
return _identity_decorator_inner
njit = _identity_decorator_outer
jit = _identity_decorator_outer
vectorize = _identity_decorator_outer
int64 = int
float64 = float
complex128 = complex
IS_PY3 = (sys.version_info[:2] >= (3, 0))
GOT_NUMBA = False
if IS_PY3:
xrange = range
else:
xrange = xrange