Skip to content

Commit be38238

Browse files
committed
Write first test in test_grd2cpt.py
1 parent e6753b8 commit be38238

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

pygmt/tests/test_grd2cpt.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
"""
2+
Tests for grd2cpt.
3+
"""
4+
import os
5+
6+
import numpy as np
7+
import pytest
8+
from pygmt import Figure, makecpt, grd2cpt
9+
from pygmt.datasets import load_earth_relief
10+
from pygmt.exceptions import GMTInvalidInput
11+
from pygmt.helpers import GMTTempFile
12+
from pygmt.helpers.testing import check_figures_equal
13+
14+
15+
@pytest.fixture(scope="module", name="grid")
16+
def fixture_grid():
17+
"""
18+
Load the grid data from the sample earth_relief file.
19+
"""
20+
return load_earth_relief()
21+
22+
@check_figures_equal()
23+
def test_grd2cpt(grid):
24+
"""
25+
Test the basic function of grd2cpt to create a CPT based off a grid input.
26+
"""
27+
fig_ref, fig_test = Figure(), Figure()
28+
fig_ref.basemap(R="0/10/0/10", J="X15c", B="a")
29+
grd2cpt(grid=grid)
30+
fig_ref.colorbar(frame="a2000")
31+
fig_test.basemap(region=[0, 10, 0, 10], projection="X15c", frame="a")
32+
grd2cpt(grid=grid)
33+
fig_test.colorbar(frame="a2000")
34+
return fig_ref, fig_test
35+

0 commit comments

Comments
 (0)