Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update output shape and mean values from some x2sys_cross tests #2986

Merged
merged 3 commits into from
Jan 16, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Comment on lines 66 to +69
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still a little unsure why GMT 6.5.0's x2sys_cross returns more rows than GMT 6.4.0. Might need to investigate.

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")
Comment on lines +146 to +148
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seisman, this is similar to your commit f97d92e in #2936, but I used a deep copy (copy.deepcopy()) instead of a shallow copy (.copy()) because setting NaNs on the shallow copy newtracks still modified the original tracks object.


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)
Loading