forked from tskit-dev/tsdate
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Copied from SGKIT. Fixes tskit-dev#438
- Loading branch information
Showing
8 changed files
with
103 additions
and
74 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import os | ||
from typing import Callable | ||
|
||
from numba import jit | ||
|
||
# By default we disable the numba cache. See | ||
_DISABLE_CACHE = os.environ.get("TSDATE_DISABLE_NUMBA_CACHE", "1") | ||
|
||
try: | ||
CACHE_NUMBA = {"0": True, "1": False}[_DISABLE_CACHE] | ||
except KeyError as e: # pragma: no cover | ||
raise KeyError( | ||
"Environment variable 'TSDATE_DISABLE_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_) |
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
Oops, something went wrong.