Skip to content

Commit d2135dc

Browse files
authored
Allow passing in list to 'region' argument in surface (#378)
1 parent de69e58 commit d2135dc

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

pygmt/gridding.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,19 @@
66
from .clib import Session
77
from .helpers import (
88
build_arg_string,
9+
data_kind,
10+
dummy_context,
911
fmt_docstring,
1012
GMTTempFile,
13+
kwargs_to_strings,
1114
use_alias,
12-
data_kind,
13-
dummy_context,
1415
)
1516
from .exceptions import GMTInvalidInput
1617

1718

1819
@fmt_docstring
1920
@use_alias(I="spacing", R="region", G="outfile")
21+
@kwargs_to_strings(R="sequence")
2022
def surface(x=None, y=None, z=None, data=None, **kwargs):
2123
"""
2224
Grids table data using adjustable tension continuous curvature splines.

pygmt/tests/test_surface.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def test_surface_input_file():
2121
Run surface by passing in a filename
2222
"""
2323
fname = which("@tut_ship.xyz", download="c")
24-
output = surface(data=fname, spacing="5m", region="245/255/20/30")
24+
output = surface(data=fname, spacing="5m", region=[245, 255, 20, 30])
2525
assert isinstance(output, xr.Dataset)
2626
return output
2727

@@ -32,7 +32,7 @@ def test_surface_input_data_array():
3232
"""
3333
ship_data = load_sample_bathymetry()
3434
data = ship_data.values # convert pandas.DataFrame to numpy.ndarray
35-
output = surface(data=data, spacing="5m", region="245/255/20/30")
35+
output = surface(data=data, spacing="5m", region=[245, 255, 20, 30])
3636
assert isinstance(output, xr.Dataset)
3737
return output
3838

@@ -47,7 +47,7 @@ def test_surface_input_xyz():
4747
y=ship_data.latitude,
4848
z=ship_data.bathymetry,
4949
spacing="5m",
50-
region="245/255/20/30",
50+
region=[245, 255, 20, 30],
5151
)
5252
assert isinstance(output, xr.Dataset)
5353
return output
@@ -63,7 +63,7 @@ def test_surface_input_xy_no_z():
6363
x=ship_data.longitude,
6464
y=ship_data.latitude,
6565
spacing="5m",
66-
region="245/255/20/30",
66+
region=[245, 255, 20, 30],
6767
)
6868

6969

@@ -75,7 +75,7 @@ def test_surface_wrong_kind_of_input():
7575
data = ship_data.bathymetry.to_xarray() # convert pandas.Series to xarray.DataArray
7676
assert data_kind(data) == "grid"
7777
with pytest.raises(GMTInvalidInput):
78-
surface(data=data, spacing="5m", region="245/255/20/30")
78+
surface(data=data, spacing="5m", region=[245, 255, 20, 30])
7979

8080

8181
def test_surface_with_outfile_param():
@@ -86,7 +86,7 @@ def test_surface_with_outfile_param():
8686
data = ship_data.values # convert pandas.DataFrame to numpy.ndarray
8787
try:
8888
output = surface(
89-
data=data, spacing="5m", region="245/255/20/30", outfile=TEMP_GRID
89+
data=data, spacing="5m", region=[245, 255, 20, 30], outfile=TEMP_GRID
9090
)
9191
assert output is None # check that output is None since outfile is set
9292
assert os.path.exists(path=TEMP_GRID) # check that outfile exists at path
@@ -104,7 +104,7 @@ def test_surface_short_aliases():
104104
ship_data = load_sample_bathymetry()
105105
data = ship_data.values # convert pandas.DataFrame to numpy.ndarray
106106
try:
107-
output = surface(data=data, I="5m", R="245/255/20/30", G=TEMP_GRID)
107+
output = surface(data=data, I="5m", R=[245, 255, 20, 30], G=TEMP_GRID)
108108
assert output is None # check that output is None since outfile is set
109109
assert os.path.exists(path=TEMP_GRID) # check that outfile exists at path
110110
grid = xr.open_dataset(TEMP_GRID)

0 commit comments

Comments
 (0)