Skip to content

Change test_grdinfo.py to use static_earth_relief #1746

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 14, 2022
Merged
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
28 changes: 12 additions & 16 deletions pygmt/tests/test_grdinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,24 @@
import numpy as np
import pytest
from pygmt import grdinfo
from pygmt.datasets import load_earth_relief
from pygmt.exceptions import GMTInvalidInput
from pygmt.helpers.testing import load_static_earth_relief


def test_grdinfo():
@pytest.fixture(scope="module", name="grid")
def fixture_grid():
"""
Make sure grdinfo works as expected.
Load the grid data from the static_earth_relief file.
"""
grid = load_earth_relief(registration="gridline")
result = grdinfo(grid=grid, force_scan=0, per_column="n")
assert result.strip() == "-180 180 -90 90 -8592.5 5559 1 1 361 181 0 1"
return load_static_earth_relief()


def test_grdinfo_file():
def test_grdinfo(grid):
"""
Test grdinfo with file input.
Make sure grdinfo works as expected.
"""
result = grdinfo(grid="@earth_relief_01d", force_scan=0, per_column="n")
assert result.strip() == "-180 180 -90 90 -8182 5651.5 1 1 360 180 1 1"
result = grdinfo(grid=grid, force_scan=0, per_column="n")
assert result.strip() == "-55 -47 -24 -10 190 981 1 1 8 14 1 1"


def test_grdinfo_fails():
Expand All @@ -33,14 +32,11 @@ def test_grdinfo_fails():
grdinfo(np.arange(10).reshape((5, 2)))


def test_grdinfo_region():
def test_grdinfo_region(grid):
"""
Check that the region argument works in grdinfo.
"""
result = grdinfo(
grid="@earth_relief_01d",
force_scan=0,
per_column="n",
region=[-170, 170, -80, 80],
grid=grid, force_scan=0, per_column="n", region=[-54, -50, -23, -20]
)
assert result.strip() == "-170 170 -80 80 -8182 5651.5 1 1 340 160 1 1"
assert result.strip() == "-54 -50 -23 -20 284.5 491 1 1 4 3 1 1"