Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion pygmt/tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ def test_io_load_dataarray():
GMTDataArrayAccessor information loaded.
"""
with GMTTempFile(suffix=".nc") as tmpfile:
rng = np.random.default_rng()
grid = xr.DataArray(
data=np.random.rand(2, 2), coords=[[0.1, 0.2], [0.3, 0.4]], dims=("x", "y")
data=rng.random((2, 2)), coords=[[0.1, 0.2], [0.3, 0.4]], dims=("x", "y")
)
grid.to_netcdf(tmpfile.name)
dataarray = load_dataarray(tmpfile.name)
Expand Down
12 changes: 6 additions & 6 deletions pygmt/tests/test_x2sys_cross.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,15 @@ def test_x2sys_cross_input_two_dataframes(mock_x2sys_home):
# Create pandas.DataFrame track tables
tracks = []
for i in range(2):
np.random.seed(seed=i)
track = pd.DataFrame(data=np.random.rand(10, 3), columns=("x", "y", "z"))
rng = np.random.default_rng(seed=i)
track = pd.DataFrame(data=rng.random((10, 3)), columns=("x", "y", "z"))
track["time"] = pd.date_range(start=f"2020-{i}1-01", periods=10, freq="min")
tracks.append(track)

output = x2sys_cross(tracks=tracks, tag=tag, coe="e")

assert isinstance(output, pd.DataFrame)
assert output.shape == (30, 12)
assert output.shape == (26, 12)
Copy link
Member

Choose a reason for hiding this comment

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

The changes make sense to me, but ping the original author @weiji14 to review.

columns = list(output.columns)
assert columns[:6] == ["x", "y", "t_1", "t_2", "dist_1", "dist_2"]
assert columns[6:] == ["head_1", "head_2", "vel_1", "vel_2", "z_X", "z_M"]
Expand Down Expand Up @@ -160,16 +160,16 @@ def test_x2sys_cross_input_two_filenames(mock_x2sys_home):

# Create temporary xyz files
for i in range(2):
np.random.seed(seed=i)
rng = np.random.default_rng(seed=i)
with open(
os.path.join(os.getcwd(), f"track_{i}.xyz"), mode="w", encoding="utf8"
) as fname:
np.savetxt(fname=fname, X=np.random.rand(10, 3))
np.savetxt(fname=fname, X=rng.random((10, 3)))

output = x2sys_cross(tracks=["track_0.xyz", "track_1.xyz"], tag=tag, coe="e")

assert isinstance(output, pd.DataFrame)
assert output.shape == (24, 12)
assert output.shape == (18, 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