Skip to content

Commit db94b91

Browse files
committed
Fix x2sys_cross tests on macOS M
1 parent 870d9c7 commit db94b91

File tree

1 file changed

+24
-13
lines changed

1 file changed

+24
-13
lines changed

pygmt/tests/test_x2sys_cross.py

+24-13
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def test_x2sys_cross_input_file_output_file():
5555
assert output is None # check that output is None since outfile is set
5656
assert outfile.stat().st_size > 0 # check that outfile exists at path
5757
result = pd.read_csv(outfile, sep="\t", comment=">", header=2)
58-
assert result.shape == (14338, 12)
58+
assert result.shape == (14374, 12) if sys.platform == "darwin" else (14338, 12)
5959
columns = list(result.columns)
6060
assert columns[:6] == ["# x", "y", "i_1", "i_2", "dist_1", "dist_2"]
6161
assert columns[6:] == ["head_1", "head_2", "vel_1", "vel_2", "z_X", "z_M"]
@@ -65,7 +65,7 @@ def test_x2sys_cross_input_file_output_file():
6565

6666
@pytest.mark.usefixtures("mock_x2sys_home")
6767
@pytest.mark.xfail(
68-
condition=Version(__gmt_version__) < Version("6.5.0") or sys.platform == "darwin",
68+
condition=Version(__gmt_version__) < Version("6.5.0"),
6969
reason="Upstream bug fixed in https://github.com/GenericMappingTools/gmt/pull/8188",
7070
)
7171
def test_x2sys_cross_input_file_output_dataframe():
@@ -79,7 +79,7 @@ def test_x2sys_cross_input_file_output_dataframe():
7979
output = x2sys_cross(tracks=["@tut_ship.xyz"], tag=tag, coe="i")
8080

8181
assert isinstance(output, pd.DataFrame)
82-
assert output.shape == (14338, 12)
82+
assert output.shape == (14374, 12) if sys.platform == "darwin" else (14338, 12)
8383
columns = list(output.columns)
8484
assert columns[:6] == ["x", "y", "i_1", "i_2", "dist_1", "dist_2"]
8585
assert columns[6:] == ["head_1", "head_2", "vel_1", "vel_2", "z_X", "z_M"]
@@ -243,7 +243,7 @@ def test_x2sys_cross_invalid_tracks_input_type(tracks):
243243

244244
@pytest.mark.usefixtures("mock_x2sys_home")
245245
@pytest.mark.xfail(
246-
condition=Version(__gmt_version__) < Version("6.5.0") or sys.platform == "darwin",
246+
condition=Version(__gmt_version__) < Version("6.5.0"),
247247
reason="Upstream bug fixed in https://github.com/GenericMappingTools/gmt/pull/8188",
248248
)
249249
def test_x2sys_cross_region_interpolation_numpoints():
@@ -264,15 +264,21 @@ def test_x2sys_cross_region_interpolation_numpoints():
264264
)
265265

266266
assert isinstance(output, pd.DataFrame)
267-
assert output.shape == (3882, 12)
268-
# Check crossover errors (z_X) and mean value of observables (z_M)
269-
npt.assert_allclose(output.z_X.mean(), -138.66, rtol=1e-4)
270-
npt.assert_allclose(output.z_M.mean(), -2896.875915)
267+
if sys.platform == "darwin":
268+
assert output.shape == (3894, 12)
269+
# Check crossover errors (z_X) and mean value of observables (z_M)
270+
npt.assert_allclose(output.z_X.mean(), -138.23215, rtol=1e-4)
271+
npt.assert_allclose(output.z_M.mean(), -2897.187545, rtol=1e-4)
272+
else:
273+
assert output.shape == (3882, 12)
274+
# Check crossover errors (z_X) and mean value of observables (z_M)
275+
npt.assert_allclose(output.z_X.mean(), -138.66, rtol=1e-4)
276+
npt.assert_allclose(output.z_M.mean(), -2896.875915, rtol=1e-4)
271277

272278

273279
@pytest.mark.usefixtures("mock_x2sys_home")
274280
@pytest.mark.xfail(
275-
condition=Version(__gmt_version__) < Version("6.5.0") or sys.platform == "darwin",
281+
condition=Version(__gmt_version__) < Version("6.5.0"),
276282
reason="Upstream bug fixed in https://github.com/GenericMappingTools/gmt/pull/8188",
277283
)
278284
def test_x2sys_cross_trackvalues():
@@ -285,7 +291,12 @@ def test_x2sys_cross_trackvalues():
285291
output = x2sys_cross(tracks=["@tut_ship.xyz"], tag=tag, trackvalues=True)
286292

287293
assert isinstance(output, pd.DataFrame)
288-
assert output.shape == (14338, 12)
289-
# Check mean of track 1 values (z_1) and track 2 values (z_2)
290-
npt.assert_allclose(output.z_1.mean(), -2422.418556, rtol=1e-4)
291-
npt.assert_allclose(output.z_2.mean(), -2402.268364, rtol=1e-4)
294+
if sys.platform == "darwin":
295+
assert output.shape == (14374, 12)
296+
# Check mean of track 1 values (z_1) and track 2 values (z_2)
297+
npt.assert_allclose(output.z_1.mean(), -2422.973372, rtol=1e-4)
298+
npt.assert_allclose(output.z_2.mean(), -2402.87476, rtol=1e-4)
299+
else:
300+
assert output.shape == (14338, 12)
301+
npt.assert_allclose(output.z_1.mean(), -2422.418556, rtol=1e-4)
302+
npt.assert_allclose(output.z_2.mean(), -2402.268364, rtol=1e-4)

0 commit comments

Comments
 (0)