7
7
from xarray import Dataset
8
8
9
9
from sgkit import variables
10
+ from sgkit .caching import CACHE_NUMBA
10
11
from sgkit .typing import ArrayLike
11
12
from sgkit .utils import (
12
13
conditional_merge_datasets ,
@@ -108,7 +109,7 @@ def parent_indices(
108
109
return conditional_merge_datasets (ds , new_ds , merge )
109
110
110
111
111
- @njit (cache = True )
112
+ @njit (cache = CACHE_NUMBA )
112
113
def topological_argsort (parent : ArrayLike ) -> ArrayLike : # pragma: no cover
113
114
"""Find a topological ordering of samples within a pedigree such
114
115
that no individual occurs before its parents.
@@ -172,7 +173,7 @@ def topological_argsort(parent: ArrayLike) -> ArrayLike: # pragma: no cover
172
173
return order [::- 1 ]
173
174
174
175
175
- @njit (cache = True )
176
+ @njit (cache = CACHE_NUMBA )
176
177
def _is_pedigree_sorted (parent : ArrayLike ) -> bool : # pragma: no cover
177
178
n_samples , n_parents = parent .shape
178
179
for i in range (n_samples ):
@@ -183,7 +184,7 @@ def _is_pedigree_sorted(parent: ArrayLike) -> bool: # pragma: no cover
183
184
return True
184
185
185
186
186
- @njit (cache = True )
187
+ @njit (cache = CACHE_NUMBA )
187
188
def _raise_on_half_founder (
188
189
parent : ArrayLike , tau : ArrayLike = None
189
190
) -> None : # pragma: no cover
@@ -202,7 +203,7 @@ def _raise_on_half_founder(
202
203
raise ValueError ("Pedigree contains half-founders" )
203
204
204
205
205
- @njit (cache = True )
206
+ @njit (cache = CACHE_NUMBA )
206
207
def _diploid_self_kinship (
207
208
kinship : ArrayLike , parent : ArrayLike , i : int
208
209
) -> None : # pragma: no cover
@@ -214,7 +215,7 @@ def _diploid_self_kinship(
214
215
kinship [i , i ] = (1 + kinship [p , q ]) / 2
215
216
216
217
217
- @njit (cache = True )
218
+ @njit (cache = CACHE_NUMBA )
218
219
def _diploid_pair_kinship (
219
220
kinship : ArrayLike , parent : ArrayLike , i : int , j : int
220
221
) -> None : # pragma: no cover
@@ -227,7 +228,7 @@ def _diploid_pair_kinship(
227
228
kinship [j , i ] = kinship_ij
228
229
229
230
230
- @njit (cache = True )
231
+ @njit (cache = CACHE_NUMBA )
231
232
def kinship_diploid (
232
233
parent : ArrayLike , allow_half_founders : bool = False , dtype : type = np .float64
233
234
) -> ArrayLike : # pragma: no cover
@@ -290,15 +291,15 @@ def kinship_diploid(
290
291
return kinship
291
292
292
293
293
- @njit (cache = True )
294
+ @njit (cache = CACHE_NUMBA )
294
295
def _inbreeding_as_self_kinship (
295
296
inbreeding : float , ploidy : int
296
297
) -> float : # pragma: no cover
297
298
"""Calculate self-kinship of an individual."""
298
299
return (1 + (ploidy - 1 ) * inbreeding ) / ploidy
299
300
300
301
301
- @njit (cache = True )
302
+ @njit (cache = CACHE_NUMBA )
302
303
def _hamilton_kerr_inbreeding_founder (
303
304
lambda_p : float , lambda_q : float , ploidy_i : int
304
305
) -> float : # pragma: no cover
@@ -310,7 +311,7 @@ def _hamilton_kerr_inbreeding_founder(
310
311
return num / denom
311
312
312
313
313
- @njit (cache = True )
314
+ @njit (cache = CACHE_NUMBA )
314
315
def _hamilton_kerr_inbreeding_non_founder (
315
316
tau_p : int ,
316
317
lambda_p : float ,
@@ -340,7 +341,7 @@ def _hamilton_kerr_inbreeding_non_founder(
340
341
return num / denom
341
342
342
343
343
- @njit (cache = True )
344
+ @njit (cache = CACHE_NUMBA )
344
345
def _hamilton_kerr_inbreeding_half_founder (
345
346
tau_p : int ,
346
347
lambda_p : float ,
@@ -374,7 +375,7 @@ def _hamilton_kerr_inbreeding_half_founder(
374
375
)
375
376
376
377
377
- @njit (cache = True )
378
+ @njit (cache = CACHE_NUMBA )
378
379
def _hamilton_kerr_self_kinship (
379
380
kinship : ArrayLike , parent : ArrayLike , tau : ArrayLike , lambda_ : ArrayLike , i : int
380
381
) -> None : # pragma: no cover
@@ -421,7 +422,7 @@ def _hamilton_kerr_self_kinship(
421
422
kinship [i , i ] = _inbreeding_as_self_kinship (inbreeding_i , ploidy_i )
422
423
423
424
424
- @njit (cache = True )
425
+ @njit (cache = CACHE_NUMBA )
425
426
def _hamilton_kerr_pair_kinship (
426
427
kinship : ArrayLike , parent : ArrayLike , tau : ArrayLike , i : int , j : int
427
428
) -> None : # pragma: no cover
@@ -435,7 +436,7 @@ def _hamilton_kerr_pair_kinship(
435
436
kinship [j , i ] = kinship_ij
436
437
437
438
438
- @njit (cache = True )
439
+ @njit (cache = CACHE_NUMBA )
439
440
def kinship_Hamilton_Kerr (
440
441
parent : ArrayLike ,
441
442
tau : ArrayLike ,
@@ -646,7 +647,7 @@ def pedigree_kinship(
646
647
return conditional_merge_datasets (ds , new_ds , merge )
647
648
648
649
649
- @vectorize (nopython = True , cache = True )
650
+ @vectorize (nopython = True , cache = CACHE_NUMBA )
650
651
def kinship_as_additive_relationship (
651
652
kinship : float , ploidy_x : int , ploidy_y : int
652
653
) -> float : # pragma: no cover
@@ -783,7 +784,7 @@ def additive_relationships(
783
784
return conditional_merge_datasets (ds , new_ds , merge )
784
785
785
786
786
- @njit (cache = True )
787
+ @njit (cache = CACHE_NUMBA )
787
788
def _update_inverse_additive_relationships (
788
789
mtx : ArrayLike ,
789
790
kinship : ArrayLike ,
@@ -838,7 +839,7 @@ def _update_inverse_additive_relationships(
838
839
mtx [i , i ] += scalar / ploidy_i
839
840
840
841
841
- @njit (cache = True )
842
+ @njit (cache = CACHE_NUMBA )
842
843
def pedigree_kinships_as_inverse_additive_relationships (
843
844
kinship : ArrayLike , parent : ArrayLike , tau : Union [ArrayLike , None ] = None
844
845
) -> ArrayLike : # pragma: no cover
0 commit comments