From c656e7f7df9015d9c052002d35fafe061a570762 Mon Sep 17 00:00:00 2001 From: Andrei Cuceu Date: Thu, 6 Jun 2024 16:13:41 -0400 Subject: [PATCH] Update with partial caching --- vega/utils.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/vega/utils.py b/vega/utils.py index 8b18a9f..90ae3fb 100644 --- a/vega/utils.py +++ b/vega/utils.py @@ -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): @@ -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.