Skip to content

Commit

Permalink
increase coverage of metpy.interpolate.points
Browse files Browse the repository at this point in the history
  • Loading branch information
akrherz committed Oct 13, 2018
1 parent 0cd2eab commit c3f4ccf
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions metpy/interpolate/tests/test_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def test_natural_neighbor_to_points(test_data, test_points):
assert_array_almost_equal(truth, img)


interp_methods = ['cressman', 'barnes']
interp_methods = ['cressman', 'barnes', 'shouldraise']


@pytest.mark.parametrize('method', interp_methods)
Expand All @@ -138,6 +138,12 @@ def test_inverse_distance_to_points(method, test_data, test_points):
extra_kw['r'] = 40
extra_kw['kappa'] = 100
test_file = 'barnes_r40_k100.npz'
elif method == 'shouldraise':
extra_kw['r'] = 40
with pytest.raises(ValueError):
inverse_distance_to_points(
obs_points, z, test_points, kind=method, **extra_kw)
return

img = inverse_distance_to_points(obs_points, z, test_points, kind=method, **extra_kw)

Expand All @@ -148,7 +154,7 @@ def test_inverse_distance_to_points(method, test_data, test_points):


interp_methods = ['natural_neighbor', 'cressman', 'barnes',
'linear', 'nearest', 'cubic', 'rbf']
'linear', 'nearest', 'cubic', 'rbf', 'shouldraise']


@pytest.mark.parametrize('method', interp_methods)
Expand All @@ -157,6 +163,9 @@ def test_interpolate_to_points(method, test_data):
xp, yp, z = test_data
obs_points = np.vstack([xp, yp]).transpose() * 10

with get_test_data('interpolation_test_points.npz') as fobj:
test_points = np.load(fobj)['points']

extra_kw = {}
if method == 'cressman':
extra_kw['search_radius'] = 200
Expand All @@ -165,9 +174,11 @@ def test_interpolate_to_points(method, test_data):
extra_kw['search_radius'] = 400
extra_kw['minimum_neighbors'] = 1
extra_kw['gamma'] = 1

with get_test_data('interpolation_test_points.npz') as fobj:
test_points = np.load(fobj)['points']
elif method == 'shouldraise':
with pytest.raises(ValueError):
interpolate_to_points(
obs_points, z, test_points, interp_type=method, **extra_kw)
return

img = interpolate_to_points(obs_points, z, test_points, interp_type=method, **extra_kw)

Expand Down

0 comments on commit c3f4ccf

Please sign in to comment.