Skip to content

Commit d2eb9f8

Browse files
committed
Drop support for GMT 6.3
1 parent 5f96b77 commit d2eb9f8

10 files changed

+15
-55
lines changed

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,
@@ -199,15 +198,8 @@ def info(self):
199198
"cores": self.get_default("API_CORES"),
200199
"grid layout": self.get_default("API_GRID_LAYOUT"),
201200
}
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")
201+
self._info["image layout"] = self.get_default("API_IMAGE_LAYOUT")
202+
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: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def timestamp(
5353
font
5454
Font of the timestamp and the optional label. Since the GMT logo has a fixed
5555
height, the font sizes are fixed to be 8-point for the timestamp and 7-point for
56-
the label. The parameter can't change the font color for GMT<=6.4.0, only the
56+
the label. The parameter can't change the font color for GMT 6.4.0, only the
5757
font style.
5858
timefmt
5959
Format string for the UNIX timestamp. The format string is parsed by the C
@@ -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

0 commit comments

Comments
 (0)