Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for a pre-built grid in LinearFast #1388

Merged
merged 3 commits into from
Mar 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@

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 @@
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

Check warning on line 45 in HARK/econforgeinterp.py

View check run for this annotation

Codecov / codecov/patch

HARK/econforgeinterp.py#L45

Added line #L45 was not covered by tests

# Set up extrapolation options
self.extrap_mode = extrap_mode
Expand Down
Loading