-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow the numba cache to be used, for development
Uses math.lgamma to allow numba caching. Copied from SGKIT. Fixes #438
- Loading branch information
Showing
12 changed files
with
168 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import os | ||
from typing import Callable | ||
|
||
from numba import jit | ||
|
||
# By default we disable the numba cache. See e.g. | ||
# https://github.com/sgkit-dev/sgkit/blob/main/sgkit/accelerate.py | ||
_ENABLE_CACHE = os.environ.get("TSDATE_ENABLE_NUMBA_CACHE", "0") | ||
|
||
try: | ||
CACHE_NUMBA = {"0": False, "1": True}[_ENABLE_CACHE] | ||
except KeyError as e: # pragma: no cover | ||
raise KeyError( | ||
"Environment variable 'TSDATE_ENABLE_NUMBA_CACHE' must be '0' or '1'" | ||
) from e | ||
|
||
|
||
DEFAULT_NUMBA_ARGS = { | ||
"nopython": True, | ||
"cache": CACHE_NUMBA, | ||
} | ||
|
||
|
||
def numba_jit(*args, **kwargs) -> Callable: # pragma: no cover | ||
kwargs_ = DEFAULT_NUMBA_ARGS.copy() | ||
kwargs_.update(kwargs) | ||
return jit(*args, **kwargs_) |
Oops, something went wrong.