Skip to content

Commit

Permalink
Update with partial caching
Browse files Browse the repository at this point in the history
  • Loading branch information
andreicuceu committed Jun 6, 2024
1 parent b67ca1e commit c656e7f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion vega/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
import os.path
from pathlib import Path
from functools import lru_cache
from cachetools import cached, LRUCache
from cachetools.keys import hashkey
from scipy.interpolate import interp1d

import vega

CACHE_SMOOTHING = LRUCache(128)


@njit
def sinc(x):
Expand Down Expand Up @@ -278,7 +282,10 @@ def compute_log_cov_det(cov_mat, data_mask):
return np.linalg.slogdet(masked_cov)[1]


@lru_cache
@cached(
cache=CACHE_SMOOTHING,
key=lambda sigma_par, sigma_trans, k_par_grid, k_trans_grid: hashkey(sigma_par, sigma_trans)
)
@njit
def compute_gauss_smoothing(sigma_par, sigma_trans, k_par_grid, k_trans_grid):
"""Compute a Gaussian smoothing factor.
Expand Down

0 comments on commit c656e7f

Please sign in to comment.