Skip to content

Commit 1b4aa90

Browse files
Separate tests of tutorial dataset and earth_relief dataset into two files (#978)
Co-authored-by: Will Schlitzer <[email protected]>
1 parent ab5def0 commit 1b4aa90

File tree

2 files changed

+62
-59
lines changed

2 files changed

+62
-59
lines changed

pygmt/tests/test_datasets.py renamed to pygmt/tests/test_datasets_earth_relief.py

Lines changed: 2 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,13 @@
11
"""
2-
Test basic functionality for loading datasets.
2+
Test basic functionality for loading Earth relief datasets.
33
"""
44
import numpy as np
55
import numpy.testing as npt
66
import pytest
7-
from pygmt.datasets import (
8-
load_earth_relief,
9-
load_japan_quakes,
10-
load_ocean_ridge_points,
11-
load_sample_bathymetry,
12-
load_usgs_quakes,
13-
)
7+
from pygmt.datasets import load_earth_relief
148
from pygmt.exceptions import GMTInvalidInput
159

1610

17-
def test_japan_quakes():
18-
"""
19-
Check that the dataset loads without errors.
20-
"""
21-
data = load_japan_quakes()
22-
assert data.shape == (115, 7)
23-
summary = data.describe()
24-
assert summary.loc["min", "year"] == 1987
25-
assert summary.loc["max", "year"] == 1988
26-
assert summary.loc["min", "month"] == 1
27-
assert summary.loc["max", "month"] == 12
28-
assert summary.loc["min", "day"] == 1
29-
assert summary.loc["max", "day"] == 31
30-
31-
32-
def test_ocean_ridge_points():
33-
"""
34-
Check that the @ridge.txt dataset loads without errors.
35-
"""
36-
data = load_ocean_ridge_points()
37-
assert data.shape == (4146, 2)
38-
summary = data.describe()
39-
assert summary.loc["min", "longitude"] == -179.9401
40-
assert summary.loc["max", "longitude"] == 179.935
41-
assert summary.loc["min", "latitude"] == -65.6182
42-
assert summary.loc["max", "latitude"] == 86.8
43-
44-
45-
def test_sample_bathymetry():
46-
"""
47-
Check that the @tut_ship.xyz dataset loads without errors.
48-
"""
49-
data = load_sample_bathymetry()
50-
assert data.shape == (82970, 3)
51-
summary = data.describe()
52-
assert summary.loc["min", "longitude"] == 245.0
53-
assert summary.loc["max", "longitude"] == 254.705
54-
assert summary.loc["min", "latitude"] == 20.0
55-
assert summary.loc["max", "latitude"] == 29.99131
56-
assert summary.loc["min", "bathymetry"] == -7708.0
57-
assert summary.loc["max", "bathymetry"] == -9.0
58-
59-
60-
def test_usgs_quakes():
61-
"""
62-
Check that the dataset loads without errors.
63-
"""
64-
data = load_usgs_quakes()
65-
assert data.shape == (1197, 22)
66-
67-
6811
def test_earth_relief_fails():
6912
"""
7013
Make sure earth relief fails for invalid resolutions.

pygmt/tests/test_datasets_tutorial.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
"""
2+
Test basic functionality for loading datasets for tutorials.
3+
"""
4+
from pygmt.datasets import (
5+
load_japan_quakes,
6+
load_ocean_ridge_points,
7+
load_sample_bathymetry,
8+
load_usgs_quakes,
9+
)
10+
11+
12+
def test_japan_quakes():
13+
"""
14+
Check that the dataset loads without errors.
15+
"""
16+
data = load_japan_quakes()
17+
assert data.shape == (115, 7)
18+
summary = data.describe()
19+
assert summary.loc["min", "year"] == 1987
20+
assert summary.loc["max", "year"] == 1988
21+
assert summary.loc["min", "month"] == 1
22+
assert summary.loc["max", "month"] == 12
23+
assert summary.loc["min", "day"] == 1
24+
assert summary.loc["max", "day"] == 31
25+
26+
27+
def test_ocean_ridge_points():
28+
"""
29+
Check that the @ridge.txt dataset loads without errors.
30+
"""
31+
data = load_ocean_ridge_points()
32+
assert data.shape == (4146, 2)
33+
summary = data.describe()
34+
assert summary.loc["min", "longitude"] == -179.9401
35+
assert summary.loc["max", "longitude"] == 179.935
36+
assert summary.loc["min", "latitude"] == -65.6182
37+
assert summary.loc["max", "latitude"] == 86.8
38+
39+
40+
def test_sample_bathymetry():
41+
"""
42+
Check that the @tut_ship.xyz dataset loads without errors.
43+
"""
44+
data = load_sample_bathymetry()
45+
assert data.shape == (82970, 3)
46+
summary = data.describe()
47+
assert summary.loc["min", "longitude"] == 245.0
48+
assert summary.loc["max", "longitude"] == 254.705
49+
assert summary.loc["min", "latitude"] == 20.0
50+
assert summary.loc["max", "latitude"] == 29.99131
51+
assert summary.loc["min", "bathymetry"] == -7708.0
52+
assert summary.loc["max", "bathymetry"] == -9.0
53+
54+
55+
def test_usgs_quakes():
56+
"""
57+
Check that the dataset loads without errors.
58+
"""
59+
data = load_usgs_quakes()
60+
assert data.shape == (1197, 22)

0 commit comments

Comments
 (0)