Shamrock
2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
pylib
shamrock
utils
numba_helper.py
1
try
:
2
from
numba
import
njit
3
from
numba.core.dispatcher
import
Dispatcher
4
5
HAS_NUMBA =
True
6
except
ImportError:
7
HAS_NUMBA =
False
8
9
10
def
maybe_njit(fn):
11
"""
12
Apply numba.njit when numba is installed, and return fn unchanged otherwise.
13
14
Functions that are already jitted are returned as is, since numba refuses to
15
jit a dispatcher a second time (e.g. a profile from shamrock.utils.disc_setup
16
handed to one of the analysis plots).
17
"""
18
if
HAS_NUMBA
and
not
isinstance(fn, Dispatcher):
19
return
njit(fn)
20
return
fn
Generated on
for Shamrock by
1.15.0