4
4
import numpy as np
5
5
import pytest
6
6
from pygmt import grdinfo
7
- from pygmt .datasets import load_earth_relief
8
7
from pygmt .exceptions import GMTInvalidInput
8
+ from pygmt .helpers .testing import load_static_earth_relief
9
9
10
10
11
- def test_grdinfo ():
11
+ @pytest .fixture (scope = "module" , name = "grid" )
12
+ def fixture_grid ():
12
13
"""
13
- Make sure grdinfo works as expected .
14
+ Load the grid data from the static_earth_relief file .
14
15
"""
15
- grid = load_earth_relief (registration = "gridline" )
16
- result = grdinfo (grid = grid , force_scan = 0 , per_column = "n" )
17
- assert result .strip () == "-180 180 -90 90 -8592.5 5559 1 1 361 181 0 1"
16
+ return load_static_earth_relief ()
18
17
19
18
20
- def test_grdinfo_file ( ):
19
+ def test_grdinfo ( grid ):
21
20
"""
22
- Test grdinfo with file input .
21
+ Make sure grdinfo works as expected .
23
22
"""
24
- result = grdinfo (grid = "@earth_relief_01d" , force_scan = 0 , per_column = "n" )
25
- assert result .strip () == "-180 180 -90 90 -8182 5651.5 1 1 360 180 1 1"
23
+ result = grdinfo (grid = grid , force_scan = 0 , per_column = "n" )
24
+ assert result .strip () == "-55 -47 -24 -10 190 981 1 1 8 14 1 1"
26
25
27
26
28
27
def test_grdinfo_fails ():
@@ -33,14 +32,11 @@ def test_grdinfo_fails():
33
32
grdinfo (np .arange (10 ).reshape ((5 , 2 )))
34
33
35
34
36
- def test_grdinfo_region ():
35
+ def test_grdinfo_region (grid ):
37
36
"""
38
37
Check that the region argument works in grdinfo.
39
38
"""
40
39
result = grdinfo (
41
- grid = "@earth_relief_01d" ,
42
- force_scan = 0 ,
43
- per_column = "n" ,
44
- region = [- 170 , 170 , - 80 , 80 ],
40
+ grid = grid , force_scan = 0 , per_column = "n" , region = [- 54 , - 50 , - 23 , - 20 ]
45
41
)
46
- assert result .strip () == "-170 170 -80 80 -8182 5651 .5 1 1 340 160 1 1"
42
+ assert result .strip () == "-54 -50 -23 -20 284 .5 491 1 1 4 3 1 1"
0 commit comments