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

0 commit comments

Comments
 (0)