Skip to content

Commit 2d1a8cc

Browse files
authored
Set minimum supported version to GMT>=6.4.0 (#3450)
1 parent a7e474c commit 2d1a8cc

15 files changed

+19
-59
lines changed

.github/workflows/ci_tests_legacy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
fail-fast: false
3636
matrix:
3737
os: [ubuntu-20.04, macos-12, windows-2019]
38-
gmt_version: ['6.3', '6.4']
38+
gmt_version: ['6.4']
3939
timeout-minutes: 30
4040
defaults:
4141
run:

doc/contributing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ the problem:
6464

6565
python <test>.py 2>&1 | awk -F': ' '$2=="GMT_Call_Command string" {print $3}'
6666

67-
where `<test>` is the name of your test script. Note that this script works only with GMT>=6.4
67+
where `<test>` is the name of your test script.
6868
* If the bug is produced when passing an in-memory data object (e.g., a
6969
pandas.DataFrame or xarray.DataArray) to a PyGMT function, try writing the
7070
data to a file (e.g., a netCDF or ASCII txt file) and passing the data file

doc/install.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,5 +308,5 @@ especially regarding transparency. If the transparency doesn't work in your figu
308308
please check your GMT and Ghostscript versions (you can run `pygmt.show_versions()`).
309309
We recommend:
310310

311-
- Ghostscript 9.53-9.56 for GMT 6.3.0/6.4.0
311+
- Ghostscript 9.53-9.56 for GMT 6.4.0 (or below)
312312
- Ghostscript 10.03 or later for GMT 6.5.0

pygmt/clib/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from pygmt.clib.session import Session, __gmt_version__
1010
from pygmt.exceptions import GMTVersionError
1111

12-
required_gmt_version = "6.3.0"
12+
required_gmt_version = "6.4.0"
1313

1414
# Check if the GMT version is older than the required version.
1515
if Version(__gmt_version__) < Version(required_gmt_version):

pygmt/clib/session.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import numpy as np
1818
import pandas as pd
1919
import xarray as xr
20-
from packaging.version import Version
2120
from pygmt.clib.conversion import (
2221
array_to_datetime,
2322
as_c_contiguous,
@@ -198,16 +197,9 @@ def info(self):
198197
"library path": self.get_default("API_LIBRARY"),
199198
"cores": self.get_default("API_CORES"),
200199
"grid layout": self.get_default("API_GRID_LAYOUT"),
200+
"image layout": self.get_default("API_IMAGE_LAYOUT"),
201+
"binary version": self.get_default("API_BIN_VERSION"),
201202
}
202-
# For GMT<6.4.0, API_IMAGE_LAYOUT is not defined if GMT is not
203-
# compiled with GDAL. Since GMT 6.4.0, GDAL is a required GMT
204-
# dependency. The code block can be refactored after we bump
205-
# the minimum required GMT version to 6.4.0.
206-
with contextlib.suppress(GMTCLibError):
207-
self._info["image layout"] = self.get_default("API_IMAGE_LAYOUT")
208-
# API_BIN_VERSION is new in GMT 6.4.0.
209-
if Version(self._info["version"]) >= Version("6.4.0"):
210-
self._info["binary version"] = self.get_default("API_BIN_VERSION")
211203
return self._info
212204

213205
def __enter__(self):

pygmt/src/timestamp.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ def timestamp(
8383
kwdict["U"] += f"{label}"
8484
kwdict["U"] += f"+j{justify}"
8585

86-
if Version(__gmt_version__) <= Version("6.4.0") and "/" not in str(offset):
87-
# Giving a single offset doesn't work in GMT <= 6.4.0.
86+
if Version(__gmt_version__) < Version("6.5.0") and "/" not in str(offset):
87+
# Giving a single offset doesn't work in GMT < 6.5.0.
8888
# See https://github.com/GenericMappingTools/gmt/issues/7107.
8989
offset = f"{offset}/{offset}"
9090
kwdict["U"] += f"+o{offset}"
@@ -98,8 +98,8 @@ def timestamp(
9898
"The given text string will be truncated to 64 characters."
9999
)
100100
warnings.warn(message=msg, category=RuntimeWarning, stacklevel=2)
101-
if Version(__gmt_version__) <= Version("6.4.0"):
102-
# workaround for GMT<=6.4.0 by overriding the 'timefmt' parameter
101+
if Version(__gmt_version__) < Version("6.5.0"):
102+
# Workaround for GMT<6.5.0 by overriding the 'timefmt' parameter
103103
timefmt = text[:64]
104104
else:
105105
kwdict["U"] += f"+t{text}"

pygmt/tests/test_accessor.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,6 @@ def test_accessor_set_non_boolean():
7373
grid.gmt.gtype = 2
7474

7575

76-
@pytest.mark.skipif(
77-
Version(__gmt_version__) < Version("6.4.0"),
78-
reason="Upstream bug fixed in https://github.com/GenericMappingTools/gmt/pull/6615",
79-
)
8076
@pytest.mark.xfail(
8177
condition=sys.platform == "win32" and Version(__gmt_version__) < Version("6.5.0"),
8278
reason="Upstream bug fixed in https://github.com/GenericMappingTools/gmt/pull/7573",

pygmt/tests/test_clib.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import xarray as xr
1212
from packaging.version import Version
1313
from pygmt import Figure, clib
14+
from pygmt.clib import required_gmt_version
1415
from pygmt.clib.conversion import dataarray_to_matrix
1516
from pygmt.clib.session import FAMILIES, VIAS
1617
from pygmt.exceptions import (
@@ -531,7 +532,7 @@ def test_get_default():
531532
with clib.Session() as lib:
532533
assert lib.get_default("API_GRID_LAYOUT") in {"rows", "columns"}
533534
assert int(lib.get_default("API_CORES")) >= 1
534-
assert Version(lib.get_default("API_VERSION")) >= Version("6.3.0")
535+
assert Version(lib.get_default("API_VERSION")) >= Version(required_gmt_version)
535536
assert lib.get_default("PROJ_LENGTH_UNIT") == "cm"
536537

537538

pygmt/tests/test_datasets_load_remote_datasets.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,8 @@ def test_load_remote_dataset_benchmark_with_region():
3232
assert data.attrs["horizontal_datum"] == "WGS84"
3333
assert data.gmt.registration == 0
3434
assert data.shape == (11, 21)
35-
# The cpt attribute was added since GMT 6.4.0
3635
# Can't access the cpt attribute using virtual files
37-
# if Version(__gmt_version__) >= Version("6.4.0"):
38-
# assert data.attrs["cpt"] == "@earth_age.cpt"
36+
# assert data.attrs["cpt"] == "@earth_age.cpt"
3937

4038

4139
def test_load_remote_dataset_invalid_resolutions():

pygmt/tests/test_grdfill.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
import numpy as np
88
import pytest
99
import xarray as xr
10-
from packaging.version import Version
1110
from pygmt import grdfill, load_dataarray
12-
from pygmt.clib import __gmt_version__
1311
from pygmt.exceptions import GMTInvalidInput
1412
from pygmt.helpers import GMTTempFile
1513
from pygmt.helpers.testing import load_static_earth_relief
@@ -86,16 +84,11 @@ def test_grdfill_dataarray_out(grid, expected_grid):
8684
xr.testing.assert_allclose(a=result, b=expected_grid)
8785

8886

89-
@pytest.mark.skipif(
90-
Version(__gmt_version__) < Version("6.4.0"),
91-
reason="Upstream bug/crash fixed in https://github.com/GenericMappingTools/gmt/pull/6418.",
92-
)
9387
def test_grdfill_asymmetric_pad(grid, expected_grid):
9488
"""
9589
Test grdfill using a region that includes the edge of the grid.
9690
97-
Regression test for
98-
https://github.com/GenericMappingTools/pygmt/issues/1745.
91+
Regression test for https://github.com/GenericMappingTools/pygmt/issues/1745.
9992
"""
10093
result = grdfill(grid=grid, mode="c20", region=[-55, -50, -24, -16])
10194
# check information of the output grid

pygmt/tests/test_grdfilter.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,11 @@
77
import numpy as np
88
import pytest
99
import xarray as xr
10-
from packaging.version import Version
1110
from pygmt import grdfilter, load_dataarray
12-
from pygmt.clib import __gmt_version__
1311
from pygmt.exceptions import GMTInvalidInput
1412
from pygmt.helpers import GMTTempFile
1513
from pygmt.helpers.testing import load_static_earth_relief
1614

17-
# GMT 6.3 on conda-forge doesn't have OpenMP enabled.
18-
cores = 2 if Version(__gmt_version__) > Version("6.3.0") else None
19-
2015

2116
@pytest.fixture(scope="module", name="grid")
2217
def fixture_grid():
@@ -51,7 +46,7 @@ def test_grdfilter_dataarray_in_dataarray_out(grid, expected_grid):
5146
Test grdfilter with an input DataArray, and output as DataArray.
5247
"""
5348
result = grdfilter(
54-
grid=grid, filter="g600", distance="4", region=[-53, -49, -20, -17], cores=cores
49+
grid=grid, filter="g600", distance="4", region=[-53, -49, -20, -17], cores=2
5550
)
5651
# check information of the output grid
5752
assert isinstance(result, xr.DataArray)

pygmt/tests/test_grdlandmask.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,10 @@
66

77
import pytest
88
import xarray as xr
9-
from packaging.version import Version
109
from pygmt import grdlandmask, load_dataarray
11-
from pygmt.clib import __gmt_version__
1210
from pygmt.exceptions import GMTInvalidInput
1311
from pygmt.helpers import GMTTempFile
1412

15-
# GMT 6.3 on conda-forge doesn't have OpenMP enabled.
16-
cores = 2 if Version(__gmt_version__) > Version("6.3.0") else None
17-
1813

1914
@pytest.fixture(scope="module", name="expected_grid")
2015
def fixture_expected_grid():
@@ -55,7 +50,7 @@ def test_grdlandmask_no_outgrid(expected_grid):
5550
"""
5651
Test grdlandmask with no set outgrid.
5752
"""
58-
result = grdlandmask(spacing=1, region=[125, 130, 30, 35], cores=cores)
53+
result = grdlandmask(spacing=1, region=[125, 130, 30, 35], cores=2)
5954
# check information of the output grid
6055
assert isinstance(result, xr.DataArray)
6156
assert result.gmt.gtype == 1 # Geographic grid

pygmt/tests/test_grdsample.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,10 @@
66

77
import pytest
88
import xarray as xr
9-
from packaging.version import Version
109
from pygmt import grdsample, load_dataarray
11-
from pygmt.clib import __gmt_version__
1210
from pygmt.helpers import GMTTempFile
1311
from pygmt.helpers.testing import load_static_earth_relief
1412

15-
# GMT 6.3 on conda-forge doesn't have OpenMP enabled.
16-
cores = 2 if Version(__gmt_version__) > Version("6.3.0") else None
17-
1813

1914
@pytest.fixture(scope="module", name="grid")
2015
def fixture_grid():
@@ -80,7 +75,7 @@ def test_grdsample_dataarray_out(grid, expected_grid, region, spacing):
8075
"""
8176
Test grdsample with no outgrid set and the spacing is changed.
8277
"""
83-
result = grdsample(grid=grid, spacing=spacing, region=region, cores=cores)
78+
result = grdsample(grid=grid, spacing=spacing, region=region, cores=2)
8479
# check information of the output grid
8580
assert isinstance(result, xr.DataArray)
8681
assert result.gmt.gtype == 1 # Geographic grid

pygmt/tests/test_sph2grd.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,9 @@
66

77
import numpy.testing as npt
88
import pytest
9-
from packaging.version import Version
109
from pygmt import sph2grd
11-
from pygmt.clib import __gmt_version__
1210
from pygmt.helpers import GMTTempFile
1311

14-
# GMT 6.3 on conda-forge doesn't have OpenMP enabled.
15-
cores = 2 if Version(__gmt_version__) > Version("6.3.0") else None
16-
1712

1813
def test_sph2grd_outgrid():
1914
"""
@@ -32,7 +27,7 @@ def test_sph2grd_no_outgrid():
3227
"""
3328
Test sph2grd with no set outgrid.
3429
"""
35-
temp_grid = sph2grd(data="@EGM96_to_36.txt", spacing=1, region="g", cores=cores)
30+
temp_grid = sph2grd(data="@EGM96_to_36.txt", spacing=1, region="g", cores=2)
3631
assert temp_grid.dims == ("y", "x")
3732
assert temp_grid.gmt.gtype == 0 # Cartesian grid
3833
assert temp_grid.gmt.registration == 0 # Gridline registration

pygmt/tests/test_subplot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def test_subplot_nrows_ncols_less_than_one_error():
104104
pass
105105

106106

107-
# Increase tolerance for compatibility with GMT 6.3 and 6.4, see
107+
# Increase tolerance for compatibility with GMT 6.4, see
108108
# https://github.com/GenericMappingTools/pygmt/pull/2454
109109
@pytest.mark.mpl_image_compare(tolerance=4.0)
110110
def test_subplot_outside_plotting_positioning():

0 commit comments

Comments
 (0)