Skip to content

Commit f81082f

Browse files
willschlitzercore-manweiji14
authored
Apply suggestions from code review
Co-authored-by: Yao Jiayuan <coreman.seism@gmail.com> Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com>
1 parent 5a8de85 commit f81082f

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

pygmt/src/grdfill.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ def grdfill(grid, **kwargs):
2525
Fill blank areas from a grid file.
2626
2727
Read a grid that presumably has unfilled holes that the user
28-
wants to fill in some fashion. Holes are identified by NaN values but
29-
this criteria can be changed. There are several different algorithms that
28+
wants to fill in some fashion. Holes are identified by NaN values but
29+
this criteria can be changed. There are several different algorithms that
3030
can be used to replace the hole values.
3131
3232
Full option list at :gmt-docs:`grdfill.html`

pygmt/tests/test_grdfill.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ def fixture_grid():
1717
Load the grid data from the sample earth_relief file and set value(s) to
1818
NaN.
1919
"""
20-
grid = load_earth_relief(registration="pixel")
21-
grid[10, 10] = np.nan
20+
grid = load_earth_relief(registration="pixel", region=[-5, 5, -5, 5])
21+
grid[3:5, 3:5] = np.nan
22+
grid[5:7, 5:7] = np.inf
2223
return grid
2324

2425

@@ -29,7 +30,11 @@ def test_grdfill_dataarray_out(grid):
2930
result = grdfill(grid=grid, mode="c20")
3031
# check information of the output grid
3132
assert isinstance(result, xr.DataArray)
32-
assert result[10, 10] == 20
33+
assert result[4, 4] == 20
34+
assert result[5, 5] == np.inf
35+
assert not result.isnull().all() # check that no NaN values exists
36+
assert result.gmt.gtype == 1 # Geographic grid
37+
assert result.gmt.registration == 1 # Pixel registration
3338

3439

3540
def test_grdfill_file_out(grid):
@@ -41,4 +46,4 @@ def test_grdfill_file_out(grid):
4146
assert result is None # return value is None
4247
assert os.path.exists(path=tmpfile.name) # check that outgrid exists
4348
result = grdinfo(tmpfile.name, per_column=True).strip()
44-
assert result == "-180 180 -90 90 -8182 5651.5 1 1 360 180 1 1"
49+
assert result == "-5 5 -5 5 -5130.5 inf 1 1 10 10 1 1"

0 commit comments

Comments
 (0)