Skip to content
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

Allow passing in list to 'region' argument in surface #378

Merged
merged 1 commit into from Nov 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions pygmt/gridding.py
Expand Up @@ -6,17 +6,19 @@
from .clib import Session
from .helpers import (
build_arg_string,
data_kind,
dummy_context,
fmt_docstring,
GMTTempFile,
kwargs_to_strings,
use_alias,
data_kind,
dummy_context,
)
from .exceptions import GMTInvalidInput


@fmt_docstring
@use_alias(I="spacing", R="region", G="outfile")
@kwargs_to_strings(R="sequence")
def surface(x=None, y=None, z=None, data=None, **kwargs):
"""
Grids table data using adjustable tension continuous curvature splines.
Expand Down
14 changes: 7 additions & 7 deletions pygmt/tests/test_surface.py
Expand Up @@ -21,7 +21,7 @@ def test_surface_input_file():
Run surface by passing in a filename
"""
fname = which("@tut_ship.xyz", download="c")
output = surface(data=fname, spacing="5m", region="245/255/20/30")
output = surface(data=fname, spacing="5m", region=[245, 255, 20, 30])
assert isinstance(output, xr.Dataset)
return output

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

Expand All @@ -47,7 +47,7 @@ def test_surface_input_xyz():
y=ship_data.latitude,
z=ship_data.bathymetry,
spacing="5m",
region="245/255/20/30",
region=[245, 255, 20, 30],
)
assert isinstance(output, xr.Dataset)
return output
Expand All @@ -63,7 +63,7 @@ def test_surface_input_xy_no_z():
x=ship_data.longitude,
y=ship_data.latitude,
spacing="5m",
region="245/255/20/30",
region=[245, 255, 20, 30],
)


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


def test_surface_with_outfile_param():
Expand All @@ -86,7 +86,7 @@ def test_surface_with_outfile_param():
data = ship_data.values # convert pandas.DataFrame to numpy.ndarray
try:
output = surface(
data=data, spacing="5m", region="245/255/20/30", outfile=TEMP_GRID
data=data, spacing="5m", region=[245, 255, 20, 30], outfile=TEMP_GRID
)
assert output is None # check that output is None since outfile is set
assert os.path.exists(path=TEMP_GRID) # check that outfile exists at path
Expand All @@ -104,7 +104,7 @@ def test_surface_short_aliases():
ship_data = load_sample_bathymetry()
data = ship_data.values # convert pandas.DataFrame to numpy.ndarray
try:
output = surface(data=data, I="5m", R="245/255/20/30", G=TEMP_GRID)
output = surface(data=data, I="5m", R=[245, 255, 20, 30], G=TEMP_GRID)
assert output is None # check that output is None since outfile is set
assert os.path.exists(path=TEMP_GRID) # check that outfile exists at path
grid = xr.open_dataset(TEMP_GRID)
Expand Down