|
6 | 6 | import numpy as np
|
7 | 7 | import pytest
|
8 | 8 | import xarray as xr
|
9 |
| -from pygmt import grdfill, load_dataarray |
| 9 | +from packaging.version import Version |
| 10 | +from pygmt import clib, grdfill, load_dataarray |
10 | 11 | from pygmt.exceptions import GMTInvalidInput
|
11 | 12 | from pygmt.helpers import GMTTempFile
|
12 | 13 | from pygmt.helpers.testing import load_static_earth_relief
|
13 | 14 |
|
| 15 | +with clib.Session() as _lib: |
| 16 | + gmt_version = Version(_lib.info["version"]) |
| 17 | + |
14 | 18 |
|
15 | 19 | @pytest.fixture(scope="module", name="grid")
|
16 | 20 | def fixture_grid():
|
@@ -82,6 +86,28 @@ def test_grdfill_dataarray_out(grid, expected_grid):
|
82 | 86 | xr.testing.assert_allclose(a=result, b=expected_grid)
|
83 | 87 |
|
84 | 88 |
|
| 89 | +@pytest.mark.skipif( |
| 90 | + gmt_version < Version("6.4.0"), |
| 91 | + reason="Upstream bug/crash fixed in https://github.com/GenericMappingTools/gmt/pull/6418.", |
| 92 | +) |
| 93 | +def test_grdfill_asymmetric_pad(grid, expected_grid): |
| 94 | + """ |
| 95 | + Test grdfill using a region that includes the edge of the grid. |
| 96 | +
|
| 97 | + Regression test for |
| 98 | + https://github.com/GenericMappingTools/pygmt/issues/1745. |
| 99 | + """ |
| 100 | + result = grdfill(grid=grid, mode="c20", region=[-55, -50, -24, -16]) |
| 101 | + # check information of the output grid |
| 102 | + assert isinstance(result, xr.DataArray) |
| 103 | + assert result.gmt.gtype == 1 # Geographic grid |
| 104 | + assert result.gmt.registration == 1 # Pixel registration |
| 105 | + # check information of the output grid |
| 106 | + xr.testing.assert_allclose( |
| 107 | + a=result, b=expected_grid.sel(lon=slice(-55, -50), lat=slice(-24, -16)) |
| 108 | + ) |
| 109 | + |
| 110 | + |
85 | 111 | def test_grdfill_file_out(grid, expected_grid):
|
86 | 112 | """
|
87 | 113 | Test grdfill with an outgrid set.
|
|
0 commit comments