6
6
import numpy .testing as npt
7
7
import pandas as pd
8
8
import pytest
9
- from pygmt import grdtrack , which
9
+ from packaging .version import Version
10
+ from pygmt import clib , grdtrack , which
10
11
from pygmt .datasets import load_earth_relief , load_ocean_ridge_points
11
12
from pygmt .exceptions import GMTInvalidInput
12
13
from pygmt .helpers import data_kind
13
14
14
15
TEST_DATA_DIR = os .path .join (os .path .dirname (__file__ ), "data" )
15
16
TEMP_TRACK = os .path .join (TEST_DATA_DIR , "tmp_track.txt" )
16
17
18
+ with clib .Session () as _lib :
19
+ gmt_version = Version (_lib .info ["version" ])
20
+
17
21
18
22
@pytest .fixture (scope = "module" , name = "dataarray" )
19
23
def fixture_dataarray ():
@@ -49,6 +53,10 @@ def fixture_ncfile():
49
53
return which ("@earth_relief_01d" , download = "a" )
50
54
51
55
56
+ @pytest .mark .xfail (
57
+ condition = gmt_version <= Version ("6.2.0" ),
58
+ reason = "Upstream bug fixed in https://github.com/GenericMappingTools/gmt/pull/5893." ,
59
+ )
52
60
def test_grdtrack_input_dataframe_and_dataarray (dataarray , dataframe ):
53
61
"""
54
62
Run grdtrack by passing in a pandas.DataFrame and xarray.DataArray as
@@ -57,11 +65,15 @@ def test_grdtrack_input_dataframe_and_dataarray(dataarray, dataframe):
57
65
output = grdtrack (points = dataframe , grid = dataarray , newcolname = "bathymetry" )
58
66
assert isinstance (output , pd .DataFrame )
59
67
assert output .columns .to_list () == ["longitude" , "latitude" , "bathymetry" ]
60
- npt .assert_allclose (output .iloc [0 ], [- 110.9536 , - 42.2489 , - 2790.488422 ])
68
+ npt .assert_allclose (output .iloc [0 ], [- 110.9536 , - 42.2489 , - 2797.394987 ])
61
69
62
70
return output
63
71
64
72
73
+ @pytest .mark .xfail (
74
+ condition = gmt_version <= Version ("6.2.0" ),
75
+ reason = "Upstream bug fixed in https://github.com/GenericMappingTools/gmt/pull/5893." ,
76
+ )
65
77
def test_grdtrack_input_csvfile_and_dataarray (dataarray , csvfile ):
66
78
"""
67
79
Run grdtrack by passing in a csvfile and xarray.DataArray as inputs.
@@ -72,7 +84,7 @@ def test_grdtrack_input_csvfile_and_dataarray(dataarray, csvfile):
72
84
assert os .path .exists (path = TEMP_TRACK ) # check that outfile exists at path
73
85
74
86
track = pd .read_csv (TEMP_TRACK , sep = "\t " , header = None , comment = ">" )
75
- npt .assert_allclose (track .iloc [0 ], [- 110.9536 , - 42.2489 , - 2790.488422 ])
87
+ npt .assert_allclose (track .iloc [0 ], [- 110.9536 , - 42.2489 , - 2797.394987 ])
76
88
finally :
77
89
os .remove (path = TEMP_TRACK )
78
90
0 commit comments