Skip to content

Commit eb9d58c

Browse files
committed
add test
1 parent 3b896ad commit eb9d58c

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

pygmt/datasets/samples.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import warnings
55

66
import pandas as pd
7+
import xarray as xr
78
from pygmt.exceptions import GMTInvalidInput
89
from pygmt.src import which
910

@@ -351,15 +352,11 @@ def _load_static_earth_relief(**kwargs):
351352
"""
352353
Load the static_earth_relief file for internal testing.
353354
354-
Parameters
355-
----------
356-
kwargs
357-
358355
Returns
359356
-------
357+
data : xarray.DataArray
358+
A grid of Earth relief for internal tests.
360359
"""
361-
fname = which("@static_earth_relief", download="c")
362-
data = pd.read_csv(
363-
fname, sep="\t", header=None, names=["longitude", "latitude", "bathymetry"]
364-
)
360+
fname = which("@static_earth_relief.nc", download="c")
361+
data = xr.open_dataarray(fname)
365362
return data

pygmt/tests/test_datasets_samples.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
"""
22
Test basic functionality for loading sample datasets.
33
"""
4+
import numpy.testing as npt
45
import pandas as pd
56
import pytest
7+
import xarray as xr
68
from pygmt.datasets import (
79
load_fractures_compilation,
810
load_hotspots,
@@ -145,3 +147,17 @@ def test_hotspots():
145147
"place_name",
146148
]
147149
assert isinstance(data, pd.DataFrame)
150+
151+
152+
def test_load_static_earth_relief():
153+
"""
154+
Check that @static_earth_relief.nc loads without errors.
155+
"""
156+
data = load_sample_data("static_earth_relief")
157+
assert data.dims == ("lat", "lon")
158+
assert data.shape == (14, 8)
159+
assert data.min() == 190
160+
assert data.max() == 981
161+
assert data.median() == 467
162+
npt.assert_allclose(data.mean(), 490.87946)
163+
assert isinstance(data, xr.DataArray)

0 commit comments

Comments
 (0)