Skip to content

Commit 9cbd8f9

Browse files
authored
Refactor x2sys_cross to remove verbose info and return output statements (#1572)
Silences captured stderr messages in the log from running x2sys_cross.
1 parent 8051339 commit 9cbd8f9

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

pygmt/tests/test_x2sys_cross.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,13 @@ def test_x2sys_cross_input_file_output_file(mock_x2sys_home):
4444
x2sys_init(tag=tag, fmtfile="xyz", force=True)
4545
outfile = os.path.join(tmpdir, "tmp_coe.txt")
4646
output = x2sys_cross(
47-
tracks=["@tut_ship.xyz"], tag=tag, coe="i", outfile=outfile, verbose="i"
47+
tracks=["@tut_ship.xyz"], tag=tag, coe="i", outfile=outfile
4848
)
4949

5050
assert output is None # check that output is None since outfile is set
5151
assert os.path.exists(path=outfile) # check that outfile exists at path
5252
_ = pd.read_csv(outfile, sep="\t", header=2) # ensure ASCII text file loads ok
5353

54-
return output
55-
5654

5755
def test_x2sys_cross_input_file_output_dataframe(mock_x2sys_home):
5856
"""
@@ -62,16 +60,14 @@ def test_x2sys_cross_input_file_output_dataframe(mock_x2sys_home):
6260
with TemporaryDirectory(prefix="X2SYS", dir=os.getcwd()) as tmpdir:
6361
tag = os.path.basename(tmpdir)
6462
x2sys_init(tag=tag, fmtfile="xyz", force=True)
65-
output = x2sys_cross(tracks=["@tut_ship.xyz"], tag=tag, coe="i", verbose="i")
63+
output = x2sys_cross(tracks=["@tut_ship.xyz"], tag=tag, coe="i")
6664

6765
assert isinstance(output, pd.DataFrame)
6866
assert output.shape == (14294, 12)
6967
columns = list(output.columns)
7068
assert columns[:6] == ["x", "y", "i_1", "i_2", "dist_1", "dist_2"]
7169
assert columns[6:] == ["head_1", "head_2", "vel_1", "vel_2", "z_X", "z_M"]
7270

73-
return output
74-
7571

7672
def test_x2sys_cross_input_dataframe_output_dataframe(mock_x2sys_home, tracks):
7773
"""
@@ -82,7 +78,7 @@ def test_x2sys_cross_input_dataframe_output_dataframe(mock_x2sys_home, tracks):
8278
tag = os.path.basename(tmpdir)
8379
x2sys_init(tag=tag, fmtfile="xyz", force=True)
8480

85-
output = x2sys_cross(tracks=tracks, tag=tag, coe="i", verbose="i")
81+
output = x2sys_cross(tracks=tracks, tag=tag, coe="i")
8682

8783
assert isinstance(output, pd.DataFrame)
8884
assert output.shape == (14, 12)
@@ -92,8 +88,6 @@ def test_x2sys_cross_input_dataframe_output_dataframe(mock_x2sys_home, tracks):
9288
assert output.dtypes["i_1"].type == np.object_
9389
assert output.dtypes["i_2"].type == np.object_
9490

95-
return output
96-
9791

9892
def test_x2sys_cross_input_two_dataframes(mock_x2sys_home):
9993
"""
@@ -120,7 +114,7 @@ def test_x2sys_cross_input_two_dataframes(mock_x2sys_home):
120114
track["time"] = pd.date_range(start=f"2020-{i}1-01", periods=10, freq="ms")
121115
tracks.append(track)
122116

123-
output = x2sys_cross(tracks=tracks, tag=tag, coe="e", verbose="i")
117+
output = x2sys_cross(tracks=tracks, tag=tag, coe="e")
124118

125119
assert isinstance(output, pd.DataFrame)
126120
assert output.shape == (30, 12)
@@ -171,9 +165,7 @@ def test_x2sys_cross_input_two_filenames(mock_x2sys_home):
171165
) as fname:
172166
np.savetxt(fname=fname, X=np.random.rand(10, 3))
173167

174-
output = x2sys_cross(
175-
tracks=["track_0.xyz", "track_1.xyz"], tag=tag, coe="e", verbose="i"
176-
)
168+
output = x2sys_cross(tracks=["track_0.xyz", "track_1.xyz"], tag=tag, coe="e")
177169

178170
assert isinstance(output, pd.DataFrame)
179171
assert output.shape == (24, 12)
@@ -182,8 +174,6 @@ def test_x2sys_cross_input_two_filenames(mock_x2sys_home):
182174
assert columns[6:] == ["head_1", "head_2", "vel_1", "vel_2", "z_X", "z_M"]
183175
_ = [os.remove(f"track_{i}.xyz") for i in range(2)] # cleanup track files
184176

185-
return output
186-
187177

188178
def test_x2sys_cross_invalid_tracks_input_type(tracks):
189179
"""

0 commit comments

Comments
 (0)