Skip to content

Commit

Permalink
Merge pull request #1388 from Mv77/plumbing/pre_built_grids
Browse files Browse the repository at this point in the history
Allow for a pre-built grid in `LinearFast`
  • Loading branch information
alanlujan91 committed Mar 2, 2024
2 parents 649d8c6 + 40dd7b3 commit 0980a76
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
10 changes: 10 additions & 0 deletions Documentation/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.1

Release date: February 28, 2024
Expand Down
12 changes: 9 additions & 3 deletions HARK/econforgeinterp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
Expand Down

0 comments on commit 0980a76

Please sign in to comment.