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

Wrap nearneighbor #1379

Merged
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
3777b07
Add implementation of nearneighbor
JamieJQuinn Jul 8, 2021
0ef1683
Improve formatting
JamieJQuinn Jul 8, 2021
1fccc07
Add nearneighbor to API index
JamieJQuinn Jul 8, 2021
91c1707
Apply suggestions from code review
JamieJQuinn Jul 13, 2021
51fa503
Fix unused import
JamieJQuinn Jul 16, 2021
0fbc83a
Update pygmt/src/nearneighbor.py
JamieJQuinn Aug 4, 2021
4ae19cb
Add similar figure to that found in GMTs nearneighbor documentation
JamieJQuinn Aug 4, 2021
cedcda2
Don't use which in test
JamieJQuinn Sep 8, 2021
a4bb96e
Name test more appropriately
JamieJQuinn Sep 8, 2021
fc43c85
Add newer common options
JamieJQuinn Sep 8, 2021
57aba71
Update pygmt/src/nearneighbor.py
JamieJQuinn Sep 8, 2021
620e99a
Remove unused import
JamieJQuinn Sep 8, 2021
62d4522
Apply suggestions from code review
weiji14 Sep 15, 2021
e09981f
Merge branch 'main' into feature/implement-nearneighbour
weiji14 Sep 15, 2021
c22ebb0
Fix lint errors
weiji14 Sep 15, 2021
38cb0f7
Set incols (i) to use sequence_comma
weiji14 Sep 16, 2021
dcdf379
Merge branch 'main' into feature/implement-nearneighbour
weiji14 Sep 16, 2021
d09d63d
Remove test_nearneighbor_input_xy_no_z
weiji14 Sep 16, 2021
3e33f3a
Ignore flake8 error using noqa W505
weiji14 Sep 17, 2021
b7fb6a9
Merge branch 'main' into feature/implement-nearneighbour
weiji14 Sep 18, 2021
6118d23
Fix incorrect indentation
weiji14 Sep 18, 2021
f344cf5
Shorten line length to under 100 using the dev image
weiji14 Sep 18, 2021
b187b4c
Merge branch 'main' into feature/implement-nearneighbour
weiji14 Sep 18, 2021
a0da121
Apply suggestions from code review
weiji14 Sep 18, 2021
3349396
Merge two tests using pytest parametrize
weiji14 Sep 18, 2021
758e8bb
Merge branch 'main' into feature/implement-nearneighbour
weiji14 Sep 20, 2021
523e5ec
Remove unused GMTInvalidInput import
weiji14 Sep 20, 2021
281c49d
Merge branch 'main' into feature/implement-nearneighbour
weiji14 Sep 22, 2021
3857cf9
Typo fixes
weiji14 Sep 22, 2021
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
Prev Previous commit
Next Next commit
Merge two tests using pytest parametrize
Check that numpy.array and xarray.Dataset inputs work.
  • Loading branch information
weiji14 committed Sep 18, 2021
commit 334939609e8d3b5533f4f81398237accba2d5bb7
27 changes: 7 additions & 20 deletions pygmt/tests/test_nearneighbor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
import os

import numpy as np
import numpy.testing as npt
import pytest
JamieJQuinn marked this conversation as resolved.
Show resolved Hide resolved
import xarray as xr
Expand All @@ -20,32 +21,18 @@ def fixture_ship_data():
return load_sample_bathymetry()


weiji14 marked this conversation as resolved.
Show resolved Hide resolved
def test_nearneighbor_input_file():
@pytest.mark.parametrize("array_func", [np.array, xr.Dataset])
def test_nearneighbor_input_data(array_func, ship_data):
"""
Run nearneighbor by passing in a filename.
Run nearneighbor by passing in a numpy.array or xarray.Dataset.
"""
output = nearneighbor(
data="@tut_ship.xyz",
spacing="5m",
region=[245, 255, 20, 30],
search_radius="10m",
)
assert isinstance(output, xr.DataArray)
assert output.gmt.registration == 0 # Gridline registration
assert output.gmt.gtype == 0 # Cartesian type
assert output.shape == (121, 121)
npt.assert_allclose(output.mean(), -2378.2385)


def test_nearneighbor_input_numpy_array(ship_data):
"""
Run nearneighbor by passing in a numpy array into data.
"""
data = ship_data.values # convert pandas.DataFrame to numpy.ndarray
data = array_func(ship_data)
output = nearneighbor(
data=data, spacing="5m", region=[245, 255, 20, 30], search_radius="10m"
)
assert isinstance(output, xr.DataArray)
JamieJQuinn marked this conversation as resolved.
Show resolved Hide resolved
assert output.gmt.registration == 0 # Gridline registration
assert output.gmt.gtype == 1 # Geographic type
assert output.shape == (121, 121)
npt.assert_allclose(output.mean(), -2378.2385)

Expand Down