Skip to content

Commit b74bc3e

Browse files
authored
Bump the required minimum GMT version to 6.1.0 (#507)
Changes: - Bump the required minimum GMT version to 6.1.0 - Fix some failing tests (only numbers, not baseline images) due to the change - of default earth relief grid registration - Remove compatibility codes for GMT 6.0 - Use pytest.mark.xfail to ignore some failures due to outdated baseline images or unknown failure reasons - The Windows builds are disabled due to crashes - The documentation building are disabled due to crashes on macos
1 parent 1027b38 commit b74bc3e

21 files changed

+96
-93
lines changed

.github/workflows/ci_tests.yaml

+13-10
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ jobs:
1919
fail-fast: false
2020
matrix:
2121
python-version: [3.6, 3.7, 3.8]
22-
os: [ubuntu-latest, macOS-latest, windows-latest]
22+
#os: [ubuntu-latest, macOS-latest, windows-latest]
23+
os: [ubuntu-latest, macOS-latest]
2324
# environmental variables used in coverage
2425
env:
2526
OS: ${{ matrix.os }}
@@ -47,7 +48,7 @@ jobs:
4748
requirements_file=full-conda-requirements.txt
4849
cat requirements.txt requirements-dev.txt > $requirements_file
4950
cat << EOF >> $requirements_file
50-
gmt=6.0.0
51+
gmt=6.1.0
5152
make
5253
codecov
5354
EOF
@@ -66,18 +67,18 @@ jobs:
6667
path: |
6768
~/.gmt/cache
6869
~/.gmt/server
69-
key: cache-gmt-${{ runner.os }}-${{ github.ref }}-20200609
70+
key: cache-gmt-${{ runner.os }}-${{ github.ref }}-20200710-2
7071
restore-keys: cache-gmt-${{ runner.os }}-refs/heads/master-
7172

7273
# Workaround for the timeouts of 'gmt which' on Linux and Windows
7374
- name: Download remote data using wget (Linux & Windows)
7475
shell: bash -l {0}
7576
run: |
7677
if [ "$RUNNER_OS" == "Windows" ]; then choco install wget; fi # install wget on Windows
77-
mkdir -p ~/.gmt ~/.gmt/cache ~/.gmt/server
78+
mkdir -p ~/.gmt ~/.gmt/cache ~/.gmt/server/earth/earth_relief/
7879
wget --no-check-certificate https://oceania.generic-mapping-tools.org/gmt_hash_server.txt -P ~/.gmt/server/
79-
for data in earth_relief_01d.grd earth_relief_30m.grd earth_relief_10m.grd; do
80-
wget --no-check-certificate https://oceania.generic-mapping-tools.org/${data} -P ~/.gmt/server/
80+
for data in earth_relief_01d_p.grd earth_relief_01d_g.grd earth_relief_30m_p.grd earth_relief_30m_g.grd earth_relief_10m_p.grd earth_relief_10m_g.grd; do
81+
wget --no-check-certificate https://oceania.generic-mapping-tools.org/server/earth/earth_relief/${data} -P ~/.gmt/server/earth/earth_relief/
8182
done
8283
for data in ridge.txt Table_5_11.txt tut_bathy.nc tut_quakes.ngdc tut_ship.xyz usgs_quakes_22.txt; do
8384
wget --no-check-certificate https://oceania.generic-mapping-tools.org/cache/${data} -P ~/.gmt/cache/
@@ -87,7 +88,9 @@ jobs:
8788
# Download remote files, if not already cached
8889
- name: Download remote data (macOS)
8990
shell: bash -l {0}
90-
run: gmt which -Gu @earth_relief_01d @earth_relief_30m @earth_relief_10m @ridge.txt @Table_5_11.txt @tut_bathy.nc @tut_quakes.ngdc @tut_ship.xyz @usgs_quakes_22.txt
91+
run: |
92+
gmt which -Ga @earth_relief_10m_p @earth_relief_10m_g @earth_relief_30m_p @earth_relief_30m_g @earth_relief_01d_p @earth_relief_01d_g
93+
gmt which -Ga @ridge.txt @Table_5_11.txt @tut_bathy.nc @tut_quakes.ngdc @tut_ship.xyz @usgs_quakes_22.txt
9194
if: steps.cache.outputs.cache-hit != 'true' && runner.os == 'macOS'
9295

9396
# Install the package that we want to test
@@ -103,9 +106,9 @@ jobs:
103106
run: make test PYTEST_EXTRA="-r P"
104107

105108
# Build the documentation
106-
- name: Build the documentation
107-
shell: bash -l {0}
108-
run: make -C doc clean all
109+
#- name: Build the documentation
110+
# shell: bash -l {0}
111+
# run: make -C doc clean all
109112

110113
# Upload coverage to Codecov
111114
- name: Upload coverage to Codecov

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ env:
2626
# The file with the listed requirements to be installed by conda
2727
- CONDA_REQUIREMENTS=requirements.txt
2828
- CONDA_REQUIREMENTS_DEV=requirements-dev.txt
29-
- CONDA_INSTALL_EXTRA="codecov twine gmt=6.0.0"
29+
- CONDA_INSTALL_EXTRA="codecov twine gmt=6.1.0"
3030
# These variables control which actions are performed in a build
3131
- DEPLOY=false
3232

doc/install.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Which GMT?
3131
PyGMT requires Generic Mapping Tools (GMT) version 6 as a minimum, which is the latest
3232
released version that can be found at
3333
the `GMT official site <https://www.generic-mapping-tools.org>`__.
34-
We need the latest GMT (>=6.0.0) since there are many changes being made to GMT itself in
34+
We need the latest GMT (>=6.1.0) since there are many changes being made to GMT itself in
3535
response to the development of PyGMT, mainly the new
3636
`modern execution mode <https://docs.generic-mapping-tools.org/latest/cookbook/introduction.html#modern-and-classic-mode>`__.
3737

environment.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ channels:
55
dependencies:
66
- python=3.7
77
- pip
8-
- gmt=6.0.0
8+
- gmt=6.1.0
99
- numpy
1010
- pandas
1111
- xarray

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"scripts": {
33
"build:miniconda": "curl -o ~/miniconda.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && bash ~/miniconda.sh -b -p $HOME/miniconda",
4-
"build:pygmt": "conda env create -f environment.yml && source activate pygmt && conda install -c conda-forge -y gmt==6.0.0 && make install",
4+
"build:pygmt": "conda env create -f environment.yml && source activate pygmt && conda install -c conda-forge -y gmt==6.1.0 && make install",
55
"build:docs": "source activate pygmt && cd doc && make all && mv _build/html ../public",
66
"build": "export PATH=$HOME/miniconda/bin:$PATH && npm run build:miniconda && npm run build:pygmt && npm run build:docs"
77
}

pygmt/clib/conversion.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ def dataarray_to_matrix(grid):
4949
>>> grid = load_earth_relief(resolution='01d')
5050
>>> matrix, region, inc = dataarray_to_matrix(grid)
5151
>>> print(region)
52-
[-180.0, 180.0, -90.0, 90.0]
52+
[-179.5, 179.5, -89.5, 89.5]
5353
>>> print(inc)
5454
[1.0, 1.0]
5555
>>> type(matrix)
5656
<class 'numpy.ndarray'>
5757
>>> print(matrix.shape)
58-
(181, 361)
58+
(180, 360)
5959
>>> matrix.flags.c_contiguous
6060
True
6161
>>> # Using a slice of the grid, the matrix will be copied to guarantee
@@ -66,7 +66,7 @@ def dataarray_to_matrix(grid):
6666
>>> print(matrix.shape)
6767
(31, 71)
6868
>>> print(region)
69-
[-150.0, -80.0, -80.0, -50.0]
69+
[-149.5, -79.5, -79.5, -49.5]
7070
>>> print(inc)
7171
[1.0, 1.0]
7272
>>> # but not if only taking every other grid point.
@@ -76,7 +76,7 @@ def dataarray_to_matrix(grid):
7676
>>> print(matrix.shape)
7777
(16, 36)
7878
>>> print(region)
79-
[-150.0, -80.0, -80.0, -50.0]
79+
[-149.5, -79.5, -79.5, -49.5]
8080
>>> print(inc)
8181
[2.0, 2.0]
8282

pygmt/clib/session.py

+11-16
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class Session:
7474
look for the shared library in the directory specified by it.
7575
7676
A ``GMTVersionError`` exception will be raised if the GMT shared library
77-
reports a version < 6.0.0.
77+
reports a version older than the required minimum GMT version.
7878
7979
The ``session_pointer`` attribute holds a ctypes pointer to the currently
8080
open session.
@@ -111,11 +111,11 @@ class Session:
111111
... )
112112
... # Read the contents of the temp file before it's deleted.
113113
... print(fout.read().strip())
114-
-180 180 -90 90 -8592.5 5559 1 1 361 181
114+
-179.5 179.5 -89.5 89.5 -8182 5651.5 1 1 360 180 0 0
115115
"""
116116

117117
# The minimum version of GMT required
118-
required_version = "6.0.0"
118+
required_version = "6.1.0"
119119

120120
@property
121121
def session_pointer(self):
@@ -924,7 +924,7 @@ def open_virtual_file(self, family, geometry, direction, data):
924924
GMT or getting it out of GMT, respectively.
925925
By default, GMT can modify the data you pass in. Add modifier
926926
``'GMT_IS_REFERENCE'`` to tell GMT the data are read-only, or
927-
``'GMT_IS_DUPLICATE'' to tell GMT to duplicate the data.
927+
``'GMT_IS_DUPLICATE'`` to tell GMT to duplicate the data.
928928
data : int
929929
The ctypes void pointer to your GMT data structure.
930930
@@ -990,12 +990,7 @@ def open_virtual_file(self, family, geometry, direction, data):
990990
valid_modifiers=["GMT_IS_REFERENCE", "GMT_IS_DUPLICATE"],
991991
)
992992

993-
# The core GMT changes GMT_STR16 to GMT_VF_LEN in 6.1.0
994-
# See https://github.com/GenericMappingTools/gmt/pull/2861
995-
if Version(self.info["version"]) < Version("6.1.0"):
996-
buff = ctp.create_string_buffer(self["GMT_STR16"])
997-
else:
998-
buff = ctp.create_string_buffer(self["GMT_VF_LEN"])
993+
buff = ctp.create_string_buffer(self["GMT_VF_LEN"])
999994

1000995
status = c_open_virtualfile(
1001996
self.session_pointer, family_int, geometry_int, direction_int, data, buff
@@ -1219,22 +1214,22 @@ def virtualfile_from_grid(self, grid):
12191214
>>> from pygmt.helpers import GMTTempFile
12201215
>>> data = load_earth_relief(resolution='01d')
12211216
>>> print(data.shape)
1222-
(181, 361)
1217+
(180, 360)
12231218
>>> print(data.lon.values.min(), data.lon.values.max())
1224-
-180.0 180.0
1219+
-179.5 179.5
12251220
>>> print(data.lat.values.min(), data.lat.values.max())
1226-
-90.0 90.0
1221+
-89.5 89.5
12271222
>>> print(data.values.min(), data.values.max())
1228-
-8592.5 5559.0
1223+
-8182.0 5651.5
12291224
>>> with Session() as ses:
12301225
... with ses.virtualfile_from_grid(data) as fin:
12311226
... # Send the output to a file so that we can read it
12321227
... with GMTTempFile() as fout:
12331228
... args = '{} -L0 -Cn ->{}'.format(fin, fout.name)
12341229
... ses.call_module('grdinfo', args)
12351230
... print(fout.read().strip())
1236-
-180 180 -90 90 -8592.5 5559 1 1 361 181
1237-
>>> # The output is: w e s n z0 z1 dx dy n_columns n_rows
1231+
-179.5 179.5 -89.5 89.5 -8182 5651.5 1 1 360 180 0 0
1232+
>>> # The output is: w e s n z0 z1 dx dy n_columns n_rows reg gtype
12381233
12391234
"""
12401235
# Conversion to a C-contiguous array needs to be done here and not in

pygmt/datasets/earth_relief.py

+4-13
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
The grids are available in various resolutions.
44
"""
55
import xarray as xr
6-
from packaging.version import Version
76

8-
from .. import clib, which
7+
from .. import which
98
from ..exceptions import GMTInvalidInput
109

1110

@@ -45,16 +44,8 @@ def load_earth_relief(resolution="01d", registration=None):
4544
_is_valid_resolution(resolution)
4645

4746
if registration in ("pixel", "gridline", None):
48-
reg = "" # If None, let GMT decide on Pixel/Gridline type
49-
with clib.Session() as lib:
50-
if registration and Version(lib.info["version"]) >= Version("6.1.0"):
51-
reg = f"_{registration[0]}"
52-
elif registration == "pixel" and Version(lib.info["version"]) < Version(
53-
"6.1.0"
54-
):
55-
raise GMTInvalidInput(
56-
"Pixel registration is only available for GMT>=6.1.0"
57-
)
47+
# If None, let GMT decide on Pixel/Gridline type
48+
reg = f"_{registration[0]}" if registration else ""
5849
else:
5950
raise GMTInvalidInput(
6051
f"Invalid grid registration: {registration}, should be either "
@@ -63,7 +54,7 @@ def load_earth_relief(resolution="01d", registration=None):
6354
"gridline-registered grid is available."
6455
)
6556

66-
fname = which(f"@earth_relief_{resolution}{reg}", download="u")
57+
fname = which(f"@earth_relief_{resolution}{reg}", download="a")
6758
grid = xr.open_dataarray(fname)
6859
# Add some metadata to the grid
6960
grid.name = "elevation"

pygmt/tests/test_basemap.py

+3
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ def test_basemap_power_axis():
5454
return fig
5555

5656

57+
@pytest.mark.xfail(
58+
reason="Baseline image not updated to use earth relief grid in GMT 6.1.0",
59+
)
5760
@pytest.mark.mpl_image_compare
5861
def test_basemap_polar():
5962
"Create a polar basemap plot"

pygmt/tests/test_clib.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def test_call_module_error_message():
161161
msg = "\n".join(
162162
[
163163
"Module 'info' failed with status code 71:",
164-
"gmtinfo [ERROR]: Error for input file: No such file (bogus-data.bla)",
164+
"gmtinfo [ERROR]: Cannot find file bogus-data.bla",
165165
]
166166
)
167167
assert str(error) == msg
@@ -797,7 +797,7 @@ def test_get_default():
797797
with clib.Session() as lib:
798798
assert lib.get_default("API_GRID_LAYOUT") in ["rows", "columns"]
799799
assert int(lib.get_default("API_CORES")) >= 1
800-
assert Version(lib.get_default("API_VERSION")) >= Version("6.0.0")
800+
assert Version(lib.get_default("API_VERSION")) >= Version("6.1.0")
801801

802802

803803
def test_get_default_fails():

pygmt/tests/test_coast.py

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ def test_coast():
2525
return fig
2626

2727

28+
@pytest.mark.xfail(
29+
reason="Baseline image not updated to use earth relief grid in GMT 6.1.0",
30+
)
2831
@pytest.mark.mpl_image_compare
2932
def test_coast_iceland():
3033
"Test passing in R as a list"

pygmt/tests/test_colorbar.py

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ def test_colorbar_positioned_using_map_coordinates():
3737
return fig
3838

3939

40+
@pytest.mark.xfail(
41+
reason="Baseline image not updated to use earth relief grid in GMT 6.1.0",
42+
)
4043
@pytest.mark.mpl_image_compare
4144
def test_colorbar_positioned_using_justification_code():
4245
"""

pygmt/tests/test_config.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
from .. import Figure, config
77

88

9+
@pytest.mark.xfail(
10+
reason="Baseline image not updated to use earth relief grid in GMT 6.1.0",
11+
)
912
@pytest.mark.mpl_image_compare
1013
def test_config():
1114
"""
@@ -37,6 +40,9 @@ def test_config():
3740
return fig
3841

3942

43+
@pytest.mark.xfail(
44+
reason="Baseline image not updated to use earth relief grid in GMT 6.1.0",
45+
)
4046
@pytest.mark.mpl_image_compare
4147
def test_config_font_one():
4248
"""
@@ -51,6 +57,9 @@ def test_config_font_one():
5157
return fig
5258

5359

60+
@pytest.mark.xfail(
61+
reason="Baseline image not updated to use earth relief grid in GMT 6.1.0",
62+
)
5463
@pytest.mark.mpl_image_compare
5564
def test_config_font_annot():
5665
"""
@@ -105,9 +114,6 @@ def test_config_map_grid_cross_size():
105114
`MAP_GRID_CROSS_SIZE_PRIMARY` and `MAP_GRID_CROSS_SIZE_SECONDARY`.
106115
"""
107116
fig = Figure()
108-
config(
109-
MAP_GRID_CROSS_SIZE_PRIMARY="0p", MAP_GRID_CROSS_SIZE_SECONDARY="0p"
110-
) # Remove after https://github.com/GenericMappingTools/gmt/issues/3062 is fixed
111117
with config(MAP_GRID_CROSS_SIZE="3p"):
112118
fig.basemap(
113119
region=["2020-1-24T21:00", "2020-1-25T00:00", 0, 1],

0 commit comments

Comments
 (0)