Skip to content

Commit 3719474

Browse files
authored
CI: Do not add the 'cores' parameters for GMT 6.3 (#3290)
1 parent 3779eca commit 3719474

File tree

4 files changed

+24
-4
lines changed

4 files changed

+24
-4
lines changed

pygmt/tests/test_grdfilter.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,16 @@
77
import numpy as np
88
import pytest
99
import xarray as xr
10+
from packaging.version import Version
1011
from pygmt import grdfilter, load_dataarray
12+
from pygmt.clib import __gmt_version__
1113
from pygmt.exceptions import GMTInvalidInput
1214
from pygmt.helpers import GMTTempFile
1315
from pygmt.helpers.testing import load_static_earth_relief
1416

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+
1520

1621
@pytest.fixture(scope="module", name="grid")
1722
def fixture_grid():
@@ -46,7 +51,7 @@ def test_grdfilter_dataarray_in_dataarray_out(grid, expected_grid):
4651
Test grdfilter with an input DataArray, and output as DataArray.
4752
"""
4853
result = grdfilter(
49-
grid=grid, filter="g600", distance="4", region=[-53, -49, -20, -17], cores=2
54+
grid=grid, filter="g600", distance="4", region=[-53, -49, -20, -17], cores=cores
5055
)
5156
# check information of the output grid
5257
assert isinstance(result, xr.DataArray)

pygmt/tests/test_grdlandmask.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@
66

77
import pytest
88
import xarray as xr
9+
from packaging.version import Version
910
from pygmt import grdlandmask, load_dataarray
11+
from pygmt.clib import __gmt_version__
1012
from pygmt.exceptions import GMTInvalidInput
1113
from pygmt.helpers import GMTTempFile
1214

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+
1318

1419
@pytest.fixture(scope="module", name="expected_grid")
1520
def fixture_expected_grid():
@@ -50,7 +55,7 @@ def test_grdlandmask_no_outgrid(expected_grid):
5055
"""
5156
Test grdlandmask with no set outgrid.
5257
"""
53-
result = grdlandmask(spacing=1, region=[125, 130, 30, 35], cores=2)
58+
result = grdlandmask(spacing=1, region=[125, 130, 30, 35], cores=cores)
5459
# check information of the output grid
5560
assert isinstance(result, xr.DataArray)
5661
assert result.gmt.gtype == 1 # Geographic grid

pygmt/tests/test_grdsample.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@
66

77
import pytest
88
import xarray as xr
9+
from packaging.version import Version
910
from pygmt import grdsample, load_dataarray
11+
from pygmt.clib import __gmt_version__
1012
from pygmt.helpers import GMTTempFile
1113
from pygmt.helpers.testing import load_static_earth_relief
1214

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+
1318

1419
@pytest.fixture(scope="module", name="grid")
1520
def fixture_grid():
@@ -75,7 +80,7 @@ def test_grdsample_dataarray_out(grid, expected_grid, region, spacing):
7580
"""
7681
Test grdsample with no outgrid set and the spacing is changed.
7782
"""
78-
result = grdsample(grid=grid, spacing=spacing, region=region, cores=2)
83+
result = grdsample(grid=grid, spacing=spacing, region=region, cores=cores)
7984
# check information of the output grid
8085
assert isinstance(result, xr.DataArray)
8186
assert result.gmt.gtype == 1 # Geographic grid

pygmt/tests/test_sph2grd.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,14 @@
66

77
import numpy.testing as npt
88
import pytest
9+
from packaging.version import Version
910
from pygmt import sph2grd
11+
from pygmt.clib import __gmt_version__
1012
from pygmt.helpers import GMTTempFile
1113

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+
1217

1318
def test_sph2grd_outgrid():
1419
"""
@@ -27,7 +32,7 @@ def test_sph2grd_no_outgrid():
2732
"""
2833
Test sph2grd with no set outgrid.
2934
"""
30-
temp_grid = sph2grd(data="@EGM96_to_36.txt", spacing=1, region="g", cores=2)
35+
temp_grid = sph2grd(data="@EGM96_to_36.txt", spacing=1, region="g", cores=cores)
3136
assert temp_grid.dims == ("y", "x")
3237
assert temp_grid.gmt.gtype == 0 # Cartesian grid
3338
assert temp_grid.gmt.registration == 0 # Gridline registration

0 commit comments

Comments
 (0)