From a7f018df9bdce88c75c6324083a46409eeef828b Mon Sep 17 00:00:00 2001 From: Mateo VG Date: Thu, 22 Feb 2024 19:02:38 -0500 Subject: [PATCH 1/2] allow for a pre-built grid --- HARK/econforgeinterp.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/HARK/econforgeinterp.py b/HARK/econforgeinterp.py index efc8c6ba8..af5d8bdd2 100644 --- a/HARK/econforgeinterp.py +++ b/HARK/econforgeinterp.py @@ -20,10 +20,10 @@ class LinearFast(MetricObject): distance_criteria = ["f_val", "grid_list"] - def __init__(self, f_val, grids, extrap_mode="linear"): + def __init__(self, f_val, grids, extrap_mode="linear", prebuilt_grid=None): """ f_val: numpy.array - An array containing the values of the function at the grid points. + An array containing the values of the function at the grid points. It's i-th dimension must be of the same lenght as the i-th grid. f_val[i,j,k] must be f(grids[0][i], grids[1][j], grids[2][k]). grids: [numpy.array] @@ -32,11 +32,17 @@ def __init__(self, f_val, grids, extrap_mode="linear"): extrap_mode: one of 'linear', 'nearest', or 'constant' Determines how to extrapolate, using either nearest point, multilinear, or constant extrapolation. The default is multilinear. + prebuilt_grid: CGrid, optional + A prebuilt CGrid object to be used as the grid. If None, a new one + will be created using the grids provided. By default None. """ self.dim = len(grids) self.f_val = f_val self.grid_list = grids - self.Grid = CGrid(*grids) + if prebuilt_grid is None: + self.Grid = CGrid(*grids) + else: + self.Grid = prebuilt_grid # Set up extrapolation options self.extrap_mode = extrap_mode From 82830e354290f40152294989fc728067a2de7ae3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateo=20Vel=C3=A1squez-Giraldo?= Date: Thu, 22 Feb 2024 20:13:25 -0500 Subject: [PATCH 2/2] Update CHANGELOG.md --- Documentation/CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Documentation/CHANGELOG.md b/Documentation/CHANGELOG.md index 3ac0ab23c..4ae68133c 100644 --- a/Documentation/CHANGELOG.md +++ b/Documentation/CHANGELOG.md @@ -8,6 +8,16 @@ For more information on HARK, see [our Github organization](https://github.com/e ## Changes +### 0.15.0 + +Release Date: TBA + +### Major Changes + +### Minor Changes + +- Add option to pass pre-built grid to `LinearFast`. [1388](https://github.com/econ-ark/HARK/pull/1388) + ### 0.14.0 Release Date: February 12, 2024