diff --git a/pygmt/clib/session.py b/pygmt/clib/session.py index 95ed8c19d76..97d25ad1c55 100644 --- a/pygmt/clib/session.py +++ b/pygmt/clib/session.py @@ -17,7 +17,6 @@ import numpy as np import pandas as pd import xarray as xr -from packaging.version import Version from pygmt.clib.conversion import ( array_to_datetime, as_c_contiguous, @@ -199,15 +198,8 @@ def info(self): "cores": self.get_default("API_CORES"), "grid layout": self.get_default("API_GRID_LAYOUT"), } - # For GMT<6.4.0, API_IMAGE_LAYOUT is not defined if GMT is not - # compiled with GDAL. Since GMT 6.4.0, GDAL is a required GMT - # dependency. The code block can be refactored after we bump - # the minimum required GMT version to 6.4.0. - with contextlib.suppress(GMTCLibError): - self._info["image layout"] = self.get_default("API_IMAGE_LAYOUT") - # API_BIN_VERSION is new in GMT 6.4.0. - if Version(self._info["version"]) >= Version("6.4.0"): - self._info["binary version"] = self.get_default("API_BIN_VERSION") + self._info["image layout"] = self.get_default("API_IMAGE_LAYOUT") + self._info["binary version"] = self.get_default("API_BIN_VERSION") return self._info def __enter__(self): diff --git a/pygmt/src/timestamp.py b/pygmt/src/timestamp.py index 39a6c25bf39..d09a86f446d 100644 --- a/pygmt/src/timestamp.py +++ b/pygmt/src/timestamp.py @@ -53,7 +53,7 @@ def timestamp( font Font of the timestamp and the optional label. Since the GMT logo has a fixed height, the font sizes are fixed to be 8-point for the timestamp and 7-point for - the label. The parameter can't change the font color for GMT<=6.4.0, only the + the label. The parameter can't change the font color for GMT 6.4.0, only the font style. timefmt Format string for the UNIX timestamp. The format string is parsed by the C @@ -83,8 +83,8 @@ def timestamp( kwdict["U"] += f"{label}" kwdict["U"] += f"+j{justify}" - if Version(__gmt_version__) <= Version("6.4.0") and "/" not in str(offset): - # Giving a single offset doesn't work in GMT <= 6.4.0. + if Version(__gmt_version__) < Version("6.5.0") and "/" not in str(offset): + # Giving a single offset doesn't work in GMT < 6.5.0. # See https://github.com/GenericMappingTools/gmt/issues/7107. offset = f"{offset}/{offset}" kwdict["U"] += f"+o{offset}" @@ -98,8 +98,8 @@ def timestamp( "The given text string will be truncated to 64 characters." ) warnings.warn(message=msg, category=RuntimeWarning, stacklevel=2) - if Version(__gmt_version__) <= Version("6.4.0"): - # workaround for GMT<=6.4.0 by overriding the 'timefmt' parameter + if Version(__gmt_version__) < Version("6.5.0"): + # Workaround for GMT<6.5.0 by overriding the 'timefmt' parameter timefmt = text[:64] else: kwdict["U"] += f"+t{text}" diff --git a/pygmt/tests/test_accessor.py b/pygmt/tests/test_accessor.py index e5e4534e1c3..2701d2a0b3a 100644 --- a/pygmt/tests/test_accessor.py +++ b/pygmt/tests/test_accessor.py @@ -73,10 +73,6 @@ def test_accessor_set_non_boolean(): grid.gmt.gtype = 2 -@pytest.mark.skipif( - Version(__gmt_version__) < Version("6.4.0"), - reason="Upstream bug fixed in https://github.com/GenericMappingTools/gmt/pull/6615", -) @pytest.mark.xfail( condition=sys.platform == "win32" and Version(__gmt_version__) < Version("6.5.0"), reason="Upstream bug fixed in https://github.com/GenericMappingTools/gmt/pull/7573", diff --git a/pygmt/tests/test_clib.py b/pygmt/tests/test_clib.py index 7591aff0729..7747c1551bc 100644 --- a/pygmt/tests/test_clib.py +++ b/pygmt/tests/test_clib.py @@ -11,6 +11,7 @@ import xarray as xr from packaging.version import Version from pygmt import Figure, clib +from pygmt.clib import required_gmt_version from pygmt.clib.conversion import dataarray_to_matrix from pygmt.clib.session import FAMILIES, VIAS from pygmt.exceptions import ( @@ -531,7 +532,7 @@ def test_get_default(): with clib.Session() as lib: assert lib.get_default("API_GRID_LAYOUT") in {"rows", "columns"} assert int(lib.get_default("API_CORES")) >= 1 - assert Version(lib.get_default("API_VERSION")) >= Version("6.3.0") + assert Version(lib.get_default("API_VERSION")) >= Version(required_gmt_version) assert lib.get_default("PROJ_LENGTH_UNIT") == "cm" diff --git a/pygmt/tests/test_datasets_load_remote_datasets.py b/pygmt/tests/test_datasets_load_remote_datasets.py index b46e21e2f94..b2de1ebddfa 100644 --- a/pygmt/tests/test_datasets_load_remote_datasets.py +++ b/pygmt/tests/test_datasets_load_remote_datasets.py @@ -32,10 +32,8 @@ def test_load_remote_dataset_benchmark_with_region(): assert data.attrs["horizontal_datum"] == "WGS84" assert data.gmt.registration == 0 assert data.shape == (11, 21) - # The cpt attribute was added since GMT 6.4.0 # Can't access the cpt attribute using virtual files - # if Version(__gmt_version__) >= Version("6.4.0"): - # assert data.attrs["cpt"] == "@earth_age.cpt" + # assert data.attrs["cpt"] == "@earth_age.cpt" def test_load_remote_dataset_invalid_resolutions(): diff --git a/pygmt/tests/test_grdfill.py b/pygmt/tests/test_grdfill.py index 35be47ebef4..f7c4730b744 100644 --- a/pygmt/tests/test_grdfill.py +++ b/pygmt/tests/test_grdfill.py @@ -7,9 +7,7 @@ import numpy as np import pytest import xarray as xr -from packaging.version import Version from pygmt import grdfill, load_dataarray -from pygmt.clib import __gmt_version__ from pygmt.exceptions import GMTInvalidInput from pygmt.helpers import GMTTempFile from pygmt.helpers.testing import load_static_earth_relief @@ -86,16 +84,11 @@ def test_grdfill_dataarray_out(grid, expected_grid): xr.testing.assert_allclose(a=result, b=expected_grid) -@pytest.mark.skipif( - Version(__gmt_version__) < Version("6.4.0"), - reason="Upstream bug/crash fixed in https://github.com/GenericMappingTools/gmt/pull/6418.", -) def test_grdfill_asymmetric_pad(grid, expected_grid): """ Test grdfill using a region that includes the edge of the grid. - Regression test for - https://github.com/GenericMappingTools/pygmt/issues/1745. + Regression test for https://github.com/GenericMappingTools/pygmt/issues/1745. """ result = grdfill(grid=grid, mode="c20", region=[-55, -50, -24, -16]) # check information of the output grid diff --git a/pygmt/tests/test_grdfilter.py b/pygmt/tests/test_grdfilter.py index a2604d8b00e..5cbe3574767 100644 --- a/pygmt/tests/test_grdfilter.py +++ b/pygmt/tests/test_grdfilter.py @@ -7,16 +7,11 @@ import numpy as np import pytest import xarray as xr -from packaging.version import Version from pygmt import grdfilter, load_dataarray -from pygmt.clib import __gmt_version__ from pygmt.exceptions import GMTInvalidInput from pygmt.helpers import GMTTempFile from pygmt.helpers.testing import load_static_earth_relief -# GMT 6.3 on conda-forge doesn't have OpenMP enabled. -cores = 2 if Version(__gmt_version__) > Version("6.3.0") else None - @pytest.fixture(scope="module", name="grid") def fixture_grid(): @@ -51,7 +46,7 @@ def test_grdfilter_dataarray_in_dataarray_out(grid, expected_grid): Test grdfilter with an input DataArray, and output as DataArray. """ result = grdfilter( - grid=grid, filter="g600", distance="4", region=[-53, -49, -20, -17], cores=cores + grid=grid, filter="g600", distance="4", region=[-53, -49, -20, -17], cores=2 ) # check information of the output grid assert isinstance(result, xr.DataArray) diff --git a/pygmt/tests/test_grdlandmask.py b/pygmt/tests/test_grdlandmask.py index d275da5cd4b..ae51ba2eda4 100644 --- a/pygmt/tests/test_grdlandmask.py +++ b/pygmt/tests/test_grdlandmask.py @@ -6,15 +6,10 @@ import pytest import xarray as xr -from packaging.version import Version from pygmt import grdlandmask, load_dataarray -from pygmt.clib import __gmt_version__ from pygmt.exceptions import GMTInvalidInput from pygmt.helpers import GMTTempFile -# GMT 6.3 on conda-forge doesn't have OpenMP enabled. -cores = 2 if Version(__gmt_version__) > Version("6.3.0") else None - @pytest.fixture(scope="module", name="expected_grid") def fixture_expected_grid(): @@ -55,7 +50,7 @@ def test_grdlandmask_no_outgrid(expected_grid): """ Test grdlandmask with no set outgrid. """ - result = grdlandmask(spacing=1, region=[125, 130, 30, 35], cores=cores) + result = grdlandmask(spacing=1, region=[125, 130, 30, 35], cores=2) # check information of the output grid assert isinstance(result, xr.DataArray) assert result.gmt.gtype == 1 # Geographic grid diff --git a/pygmt/tests/test_grdsample.py b/pygmt/tests/test_grdsample.py index 11812a1226a..4c9e64139c3 100644 --- a/pygmt/tests/test_grdsample.py +++ b/pygmt/tests/test_grdsample.py @@ -6,15 +6,10 @@ import pytest import xarray as xr -from packaging.version import Version from pygmt import grdsample, load_dataarray -from pygmt.clib import __gmt_version__ from pygmt.helpers import GMTTempFile from pygmt.helpers.testing import load_static_earth_relief -# GMT 6.3 on conda-forge doesn't have OpenMP enabled. -cores = 2 if Version(__gmt_version__) > Version("6.3.0") else None - @pytest.fixture(scope="module", name="grid") def fixture_grid(): @@ -80,7 +75,7 @@ def test_grdsample_dataarray_out(grid, expected_grid, region, spacing): """ Test grdsample with no outgrid set and the spacing is changed. """ - result = grdsample(grid=grid, spacing=spacing, region=region, cores=cores) + result = grdsample(grid=grid, spacing=spacing, region=region, cores=2) # check information of the output grid assert isinstance(result, xr.DataArray) assert result.gmt.gtype == 1 # Geographic grid diff --git a/pygmt/tests/test_sph2grd.py b/pygmt/tests/test_sph2grd.py index 820b8923240..89b4abeff25 100644 --- a/pygmt/tests/test_sph2grd.py +++ b/pygmt/tests/test_sph2grd.py @@ -6,14 +6,9 @@ import numpy.testing as npt import pytest -from packaging.version import Version from pygmt import sph2grd -from pygmt.clib import __gmt_version__ from pygmt.helpers import GMTTempFile -# GMT 6.3 on conda-forge doesn't have OpenMP enabled. -cores = 2 if Version(__gmt_version__) > Version("6.3.0") else None - def test_sph2grd_outgrid(): """ @@ -32,7 +27,7 @@ def test_sph2grd_no_outgrid(): """ Test sph2grd with no set outgrid. """ - temp_grid = sph2grd(data="@EGM96_to_36.txt", spacing=1, region="g", cores=cores) + temp_grid = sph2grd(data="@EGM96_to_36.txt", spacing=1, region="g", cores=2) assert temp_grid.dims == ("y", "x") assert temp_grid.gmt.gtype == 0 # Cartesian grid assert temp_grid.gmt.registration == 0 # Gridline registration