diff --git a/.github/workflows/ci_tests_legacy.yaml b/.github/workflows/ci_tests_legacy.yaml index 17967e1d164..b485e258a16 100644 --- a/.github/workflows/ci_tests_legacy.yaml +++ b/.github/workflows/ci_tests_legacy.yaml @@ -35,7 +35,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-20.04, macos-12, windows-2019] - gmt_version: ['6.3', '6.4'] + gmt_version: ['6.4'] timeout-minutes: 30 defaults: run: diff --git a/doc/contributing.md b/doc/contributing.md index d5ac0ac1875..5dd93418f53 100644 --- a/doc/contributing.md +++ b/doc/contributing.md @@ -64,7 +64,7 @@ the problem: python .py 2>&1 | awk -F': ' '$2=="GMT_Call_Command string" {print $3}' - where `` is the name of your test script. Note that this script works only with GMT>=6.4 + where `` is the name of your test script. * If the bug is produced when passing an in-memory data object (e.g., a pandas.DataFrame or xarray.DataArray) to a PyGMT function, try writing the data to a file (e.g., a netCDF or ASCII txt file) and passing the data file diff --git a/doc/install.md b/doc/install.md index e94b68ee914..b050f39d10a 100644 --- a/doc/install.md +++ b/doc/install.md @@ -308,5 +308,5 @@ especially regarding transparency. If the transparency doesn't work in your figu please check your GMT and Ghostscript versions (you can run `pygmt.show_versions()`). We recommend: -- Ghostscript 9.53-9.56 for GMT 6.3.0/6.4.0 +- Ghostscript 9.53-9.56 for GMT 6.4.0 (or below) - Ghostscript 10.03 or later for GMT 6.5.0 diff --git a/pygmt/clib/__init__.py b/pygmt/clib/__init__.py index 9f145716f0e..3d5d6b1a507 100644 --- a/pygmt/clib/__init__.py +++ b/pygmt/clib/__init__.py @@ -9,7 +9,7 @@ from pygmt.clib.session import Session, __gmt_version__ from pygmt.exceptions import GMTVersionError -required_gmt_version = "6.3.0" +required_gmt_version = "6.4.0" # Check if the GMT version is older than the required version. if Version(__gmt_version__) < Version(required_gmt_version): diff --git a/pygmt/clib/session.py b/pygmt/clib/session.py index 95ed8c19d76..376d441746a 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, @@ -198,16 +197,9 @@ def info(self): "library path": self.get_default("API_LIBRARY"), "cores": self.get_default("API_CORES"), "grid layout": self.get_default("API_GRID_LAYOUT"), + "image layout": self.get_default("API_IMAGE_LAYOUT"), + "binary version": self.get_default("API_BIN_VERSION"), } - # 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") return self._info def __enter__(self): diff --git a/pygmt/src/timestamp.py b/pygmt/src/timestamp.py index 39a6c25bf39..9818a289974 100644 --- a/pygmt/src/timestamp.py +++ b/pygmt/src/timestamp.py @@ -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 diff --git a/pygmt/tests/test_subplot.py b/pygmt/tests/test_subplot.py index c6b2109d0fe..2de10bd02e3 100644 --- a/pygmt/tests/test_subplot.py +++ b/pygmt/tests/test_subplot.py @@ -104,7 +104,7 @@ def test_subplot_nrows_ncols_less_than_one_error(): pass -# Increase tolerance for compatibility with GMT 6.3 and 6.4, see +# Increase tolerance for compatibility with GMT 6.4, see # https://github.com/GenericMappingTools/pygmt/pull/2454 @pytest.mark.mpl_image_compare(tolerance=4.0) def test_subplot_outside_plotting_positioning():