1
1
"""
2
2
Test pygmt.x2sys_cross.
3
3
"""
4
+ import copy
4
5
import os
5
6
from pathlib import Path
6
7
from tempfile import TemporaryDirectory
@@ -65,7 +66,7 @@ def test_x2sys_cross_input_file_output_dataframe():
65
66
output = x2sys_cross (tracks = ["@tut_ship.xyz" ], tag = tag , coe = "i" )
66
67
67
68
assert isinstance (output , pd .DataFrame )
68
- assert output .shape == (14294 , 12 )
69
+ assert output .shape == (14338 , 12 )
69
70
columns = list (output .columns )
70
71
assert columns [:6 ] == ["x" , "y" , "i_1" , "i_2" , "dist_1" , "dist_2" ]
71
72
assert columns [6 :] == ["head_1" , "head_2" , "vel_1" , "vel_2" , "z_X" , "z_M" ]
@@ -142,8 +143,9 @@ def test_x2sys_cross_input_dataframe_with_nan(tracks):
142
143
tag = tag , fmtfile = "xyz" , suffix = "xyzt" , units = ["de" , "se" ], force = True
143
144
)
144
145
145
- tracks [0 ].loc [tracks [0 ]["z" ] < - 15 , "z" ] = np .nan # set some values to NaN
146
- output = x2sys_cross (tracks = tracks , tag = tag , coe = "i" )
146
+ newtracks = copy .deepcopy (x = tracks )
147
+ newtracks [0 ].loc [newtracks [0 ]["z" ] < - 15 , "z" ] = np .nan # set some NaN values
148
+ output = x2sys_cross (tracks = newtracks , tag = tag , coe = "i" )
147
149
148
150
assert isinstance (output , pd .DataFrame )
149
151
assert output .shape == (3 , 12 )
@@ -212,10 +214,10 @@ def test_x2sys_cross_region_interpolation_numpoints():
212
214
)
213
215
214
216
assert isinstance (output , pd .DataFrame )
215
- assert output .shape == (3867 , 12 )
217
+ assert output .shape == (3882 , 12 )
216
218
# Check crossover errors (z_X) and mean value of observables (z_M)
217
- npt .assert_allclose (output .z_X .mean (), - 139.2 , rtol = 1e-4 )
218
- npt .assert_allclose (output .z_M .mean (), - 2890.465813 )
219
+ npt .assert_allclose (output .z_X .mean (), - 138.66 , rtol = 1e-4 )
220
+ npt .assert_allclose (output .z_M .mean (), - 2896.875915 )
219
221
220
222
221
223
@pytest .mark .usefixtures ("mock_x2sys_home" )
@@ -229,7 +231,7 @@ def test_x2sys_cross_trackvalues():
229
231
output = x2sys_cross (tracks = ["@tut_ship.xyz" ], tag = tag , trackvalues = True )
230
232
231
233
assert isinstance (output , pd .DataFrame )
232
- assert output .shape == (14294 , 12 )
234
+ assert output .shape == (14338 , 12 )
233
235
# Check mean of track 1 values (z_1) and track 2 values (z_2)
234
- npt .assert_allclose (output .z_1 .mean (), - 2420.569767 )
235
- npt .assert_allclose (output .z_2 .mean (), - 2400.357549 )
236
+ npt .assert_allclose (output .z_1 .mean (), - 2422.418556 )
237
+ npt .assert_allclose (output .z_2 .mean (), - 2402.268364 )
0 commit comments