Skip to content

Commit 4a9b70b

Browse files
authored
Remove deprecated codes after dropping GMT 6.4 support (#4128)
1 parent 90e1f8a commit 4a9b70b

File tree

8 files changed

+6
-99
lines changed

8 files changed

+6
-99
lines changed

pygmt/figure.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -269,12 +269,6 @@ def savefig(
269269
kwargs.pop("metadata", None)
270270
self.psconvert(prefix=prefix, fmt=fmts[ext], crop=crop, **kwargs)
271271

272-
# TODO(GMT>=6.5.0): Remove the workaround for upstream bug in GMT<6.5.0.
273-
# Remove the .pgw world file if exists. Not necessary after GMT 6.5.0.
274-
# See upstream fix https://github.com/GenericMappingTools/gmt/pull/7865
275-
if ext == "tiff":
276-
fname.with_suffix(".pgw").unlink(missing_ok=True)
277-
278272
# Rename if file extension doesn't match the input file suffix.
279273
if ext != suffix[1:]:
280274
fname.with_suffix("." + ext).rename(fname)

pygmt/src/ternary.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55
from collections.abc import Sequence
66
from typing import Literal
77

8-
import pandas as pd
9-
from packaging.version import Version
108
from pygmt._typing import PathLike, TableLike
119
from pygmt.alias import Alias, AliasSystem
12-
from pygmt.clib import Session, __gmt_version__
10+
from pygmt.clib import Session
1311
from pygmt.helpers import build_arg_list, fmt_docstring, kwargs_to_strings, use_alias
1412

1513

@@ -107,11 +105,6 @@ def ternary(
107105
)
108106
aliasdict.merge(kwargs)
109107

110-
# TODO(GMT>=6.5.0): Remove the patch for upstream bug fixed in GMT 6.5.0.
111-
# See https://github.com/GenericMappingTools/pygmt/pull/2138
112-
if Version(__gmt_version__) < Version("6.5.0") and isinstance(data, pd.DataFrame):
113-
data = data.to_numpy()
114-
115108
with Session() as lib:
116109
with lib.virtualfile_in(check_kind="vector", data=data) as vintbl:
117110
lib.call_module(

pygmt/src/timestamp.py

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
import warnings
66
from collections.abc import Sequence
77

8-
from packaging.version import Version
98
from pygmt._typing import AnchorCode
109
from pygmt.alias import Alias, AliasSystem
11-
from pygmt.clib import Session, __gmt_version__
10+
from pygmt.clib import Session
1211
from pygmt.helpers import build_arg_list
1312

1413
__doctest_skip__ = ["timestamp"]
@@ -52,8 +51,7 @@ def timestamp(
5251
font
5352
Font of the timestamp and the optional label. Since the GMT logo has a fixed
5453
height, the font sizes are fixed to be 8-point for the timestamp and 7-point for
55-
the label. The parameter can't change the font color for GMT<=6.4.0, only the
56-
font style.
54+
the label.
5755
timefmt
5856
Format string for the UNIX timestamp. The format string is parsed by the C
5957
function ``strftime``, so that virtually any text can be used (even not
@@ -84,20 +82,6 @@ def timestamp(
8482
warnings.warn(message=msg, category=RuntimeWarning, stacklevel=2)
8583
text = str(text)[:64]
8684

87-
# TODO(GMT>=6.5.0): Remove the patch for upstream "offset" bug fixed in GMT 6.5.0.
88-
# TODO(GMT>=6.5.0): Remove the workaround for the '+t' modifier added in GMT 6.5.0.
89-
# Related issues:
90-
# - https://github.com/GenericMappingTools/gmt/issues/7107
91-
# - https://github.com/GenericMappingTools/gmt/pull/7127
92-
if Version(__gmt_version__) < Version("6.5.0"):
93-
if "/" not in str(offset): # Giving a single offset doesn't work in GMT<6.5.0
94-
offset = f"{offset}/{offset}"
95-
if text is not None:
96-
# Workaround for GMT<6.5.0 by overriding the 'timefmt' parameter and
97-
# unsetting 'text'.
98-
timefmt = str(text)
99-
text = None
100-
10185
aliasdict = AliasSystem(
10286
U=[
10387
Alias(label, name="label"),

pygmt/tests/test_binstats.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66

77
import numpy.testing as npt
88
import pytest
9-
from packaging.version import Version
109
from pygmt import binstats
11-
from pygmt.clib import __gmt_version__
1210
from pygmt.enums import GridRegistration, GridType
1311
from pygmt.helpers import GMTTempFile
1412

@@ -53,11 +51,6 @@ def test_binstats_no_outgrid():
5351
npt.assert_allclose(temp_grid.mean(), 4227489)
5452

5553

56-
# TODO(GMT>=6.5.0): Remove the xfail marker for the upstream bug fixed in GMT 6.5.0.
57-
@pytest.mark.xfail(
58-
condition=Version(__gmt_version__) < Version("6.5.0"),
59-
reason="Upstream bug fixed in https://github.com/GenericMappingTools/gmt/pull/8243",
60-
)
6154
def test_binstats_quantile():
6255
"""
6356
Test binstats quantile statistic functionality.

pygmt/tests/test_meca.py

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
import numpy as np
88
import pandas as pd
99
import pytest
10-
from packaging.version import Version
1110
from pygmt import Figure
12-
from pygmt.clib import __gmt_version__
1311
from pygmt.exceptions import GMTInvalidInput, GMTValueError
1412
from pygmt.helpers import GMTTempFile
1513

@@ -143,21 +141,10 @@ def test_meca_spec_multiple_focalmecha(inputtype):
143141
return fig
144142

145143

146-
# TODO(GMT>=6.5.0): Remove the skipif condition for GMT>=6.5.0.
147144
@pytest.mark.mpl_image_compare(filename="test_meca_offset.png")
148145
@pytest.mark.parametrize(
149146
"inputtype",
150-
[
151-
"args",
152-
"dict",
153-
pytest.param(
154-
"ndarray",
155-
marks=pytest.mark.skipif(
156-
condition=Version(__gmt_version__) < Version("6.5.0"),
157-
reason="Upstream bug fixed in https://github.com/GenericMappingTools/gmt/pull/7557",
158-
),
159-
),
160-
],
147+
["args", "dict", "ndarray"],
161148
)
162149
def test_meca_offset(inputtype):
163150
"""
@@ -202,22 +189,10 @@ def test_meca_offset(inputtype):
202189
return fig
203190

204191

205-
# TODO(GMT>=6.5.0): Remove the skipif marker for GMT>=6.5.0.
206-
# Passing event names via pandas doesn't work for GMT<=6.4.
207-
# See https://github.com/GenericMappingTools/pygmt/issues/2524.
208192
@pytest.mark.mpl_image_compare(filename="test_meca_eventname.png")
209193
@pytest.mark.parametrize(
210194
"inputtype",
211-
[
212-
"args",
213-
pytest.param(
214-
"dataframe",
215-
marks=pytest.mark.skipif(
216-
condition=Version(__gmt_version__) < Version("6.5.0"),
217-
reason="Upstream bug fixed in https://github.com/GenericMappingTools/gmt/pull/7557",
218-
),
219-
),
220-
],
195+
["args", "dataframe"],
221196
)
222197
def test_meca_eventname(inputtype):
223198
"""

pygmt/tests/test_subplot.py

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

106106

107-
# Increase tolerance for compatibility with GMT 6.4, see
108-
# https://github.com/GenericMappingTools/pygmt/pull/2454
109-
@pytest.mark.mpl_image_compare(tolerance=4.0)
107+
@pytest.mark.mpl_image_compare()
110108
def test_subplot_outside_plotting_positioning():
111109
"""
112110
Plotting calls are correctly positioned after exiting subplot.

pygmt/tests/test_x2sys_cross.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
import numpy.testing as npt
1313
import pandas as pd
1414
import pytest
15-
from packaging.version import Version
1615
from pygmt import config, x2sys_cross, x2sys_init
17-
from pygmt.clib import __gmt_version__
1816
from pygmt.datasets import load_sample_data
1917
from pygmt.exceptions import GMTTypeError
2018

@@ -38,12 +36,7 @@ def fixture_tracks():
3836
return [dataframe.query(expr="z > -20")] # reduce size of dataset
3937

4038

41-
# TODO(GMT>=6.5.0): Remove the xfail marker for the upstream bug fixed in GMT 6.5.0.
4239
@pytest.mark.usefixtures("mock_x2sys_home")
43-
@pytest.mark.xfail(
44-
condition=Version(__gmt_version__) < Version("6.5.0"),
45-
reason="Upstream bug fixed in https://github.com/GenericMappingTools/gmt/pull/8188",
46-
)
4740
def test_x2sys_cross_input_file_output_file():
4841
"""
4942
Run x2sys_cross by passing in a filename, and output internal crossovers to an ASCII
@@ -68,12 +61,7 @@ def test_x2sys_cross_input_file_output_file():
6861
npt.assert_allclose(result["i_1"].max(), 82945.9370, rtol=1.0e-4)
6962

7063

71-
# TODO(GMT>=6.5.0): Remove the xfail marker for the upstream bug fixed in GMT 6.5.0.
7264
@pytest.mark.usefixtures("mock_x2sys_home")
73-
@pytest.mark.xfail(
74-
condition=Version(__gmt_version__) < Version("6.5.0"),
75-
reason="Upstream bug fixed in https://github.com/GenericMappingTools/gmt/pull/8188",
76-
)
7765
def test_x2sys_cross_input_file_output_dataframe():
7866
"""
7967
Run x2sys_cross by passing in a filename, and output internal crossovers to a
@@ -247,12 +235,7 @@ def test_x2sys_cross_invalid_tracks_input_type(tracks):
247235
x2sys_cross(tracks=[invalid_tracks])
248236

249237

250-
# TODO(GMT>=6.5.0): Remove the xfail marker for the upstream bug fixed in GMT 6.5.0.
251238
@pytest.mark.usefixtures("mock_x2sys_home")
252-
@pytest.mark.xfail(
253-
condition=Version(__gmt_version__) < Version("6.5.0"),
254-
reason="Upstream bug fixed in https://github.com/GenericMappingTools/gmt/pull/8188",
255-
)
256239
def test_x2sys_cross_region_interpolation_numpoints():
257240
"""
258241
Test that x2sys_cross's region (R), interpolation (l) and numpoints (W) arguments
@@ -283,12 +266,7 @@ def test_x2sys_cross_region_interpolation_numpoints():
283266
npt.assert_allclose(output.z_M.mean(), -2896.875915, rtol=1e-4)
284267

285268

286-
# TODO(GMT>=6.5.0): Remove the xfail marker for the upstream bug fixed in GMT 6.5.0.
287269
@pytest.mark.usefixtures("mock_x2sys_home")
288-
@pytest.mark.xfail(
289-
condition=Version(__gmt_version__) < Version("6.5.0"),
290-
reason="Upstream bug fixed in https://github.com/GenericMappingTools/gmt/pull/8188",
291-
)
292270
def test_x2sys_cross_trackvalues():
293271
"""
294272
Test that x2sys_cross's trackvalues (Z) argument work.

pygmt/tests/test_xarray_accessor.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,11 @@
33
"""
44

55
import importlib
6-
import sys
76
from pathlib import Path
87

98
import pytest
109
import xarray as xr
11-
from packaging.version import Version
1210
from pygmt import which
13-
from pygmt.clib import __gmt_version__
1411
from pygmt.datasets import load_earth_relief
1512
from pygmt.enums import GridRegistration, GridType
1613
from pygmt.exceptions import GMTValueError
@@ -113,12 +110,7 @@ def test_xarray_accessor_set_invalid_registration_and_gtype():
113110
grid.gmt.gtype = "geographic"
114111

115112

116-
# TODO(GMT>=6.5.0): Remove the xfail marker for GMT>=6.5.0.
117113
@pytest.mark.skipif(condition=not _HAS_NETCDF4, reason="netCDF4 is not installed")
118-
@pytest.mark.xfail(
119-
condition=sys.platform == "win32" and Version(__gmt_version__) < Version("6.5.0"),
120-
reason="Upstream bug fixed in https://github.com/GenericMappingTools/gmt/pull/7573",
121-
)
122114
def test_xarray_accessor_sliced_datacube():
123115
"""
124116
Check that a 2-D grid which is sliced from an n-dimensional datacube works with

0 commit comments

Comments
 (0)