Skip to content

Commit

Permalink
Update output shape and mean values from some x2sys_cross tests (#2986)
Browse files Browse the repository at this point in the history
  • Loading branch information
weiji14 committed Jan 16, 2024
1 parent ec75e7b commit d15c79f
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions pygmt/tests/test_x2sys_cross.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Test pygmt.x2sys_cross.
"""
import copy
import os
from pathlib import Path
from tempfile import TemporaryDirectory
Expand Down Expand Up @@ -65,7 +66,7 @@ def test_x2sys_cross_input_file_output_dataframe():
output = x2sys_cross(tracks=["@tut_ship.xyz"], tag=tag, coe="i")

assert isinstance(output, pd.DataFrame)
assert output.shape == (14294, 12)
assert output.shape == (14338, 12)
columns = list(output.columns)
assert columns[:6] == ["x", "y", "i_1", "i_2", "dist_1", "dist_2"]
assert columns[6:] == ["head_1", "head_2", "vel_1", "vel_2", "z_X", "z_M"]
Expand Down Expand Up @@ -142,8 +143,9 @@ def test_x2sys_cross_input_dataframe_with_nan(tracks):
tag=tag, fmtfile="xyz", suffix="xyzt", units=["de", "se"], force=True
)

tracks[0].loc[tracks[0]["z"] < -15, "z"] = np.nan # set some values to NaN
output = x2sys_cross(tracks=tracks, tag=tag, coe="i")
newtracks = copy.deepcopy(x=tracks)
newtracks[0].loc[newtracks[0]["z"] < -15, "z"] = np.nan # set some NaN values
output = x2sys_cross(tracks=newtracks, tag=tag, coe="i")

assert isinstance(output, pd.DataFrame)
assert output.shape == (3, 12)
Expand Down Expand Up @@ -212,10 +214,10 @@ def test_x2sys_cross_region_interpolation_numpoints():
)

assert isinstance(output, pd.DataFrame)
assert output.shape == (3867, 12)
assert output.shape == (3882, 12)
# Check crossover errors (z_X) and mean value of observables (z_M)
npt.assert_allclose(output.z_X.mean(), -139.2, rtol=1e-4)
npt.assert_allclose(output.z_M.mean(), -2890.465813)
npt.assert_allclose(output.z_X.mean(), -138.66, rtol=1e-4)
npt.assert_allclose(output.z_M.mean(), -2896.875915)


@pytest.mark.usefixtures("mock_x2sys_home")
Expand All @@ -229,7 +231,7 @@ def test_x2sys_cross_trackvalues():
output = x2sys_cross(tracks=["@tut_ship.xyz"], tag=tag, trackvalues=True)

assert isinstance(output, pd.DataFrame)
assert output.shape == (14294, 12)
assert output.shape == (14338, 12)
# Check mean of track 1 values (z_1) and track 2 values (z_2)
npt.assert_allclose(output.z_1.mean(), -2420.569767)
npt.assert_allclose(output.z_2.mean(), -2400.357549)
npt.assert_allclose(output.z_1.mean(), -2422.418556)
npt.assert_allclose(output.z_2.mean(), -2402.268364)

0 comments on commit d15c79f

Please sign in to comment.