def test_interpolate_nan_linear(): """Test linear interpolation of arrays with NaNs in the y-coordinate.""" x = np.linspace(0, 20, 15) y = 5 * x + 3 nan_indexes = [1, 5, 11, 12] y_with_nan = y.copy() y_with_nan[nan_indexes] = np.nan assert_array_almost_equal(y, interpolate_nans(x, y_with_nan), 2)
def test_interpolate_nan_linear(): """Test deprecated interpolate_nans function.""" x = np.linspace(0, 20, 15) y = 5 * x + 3 nan_indexes = [1, 5, 11, 12] y_with_nan = y.copy() y_with_nan[nan_indexes] = np.nan assert_array_almost_equal(y, interpolate_nans(x, y_with_nan), 2)
def test_interpolate_nan_log(): """Test log interpolation of arrays with NaNs in the y-coordinate.""" x = np.logspace(1, 5, 15) y = 5 * np.log(x) + 3 nan_indexes = [1, 5, 11, 12] y_with_nan = y.copy() y_with_nan[nan_indexes] = np.nan assert_array_almost_equal(y, interpolate_nans(x, y_with_nan, kind='log'), 2)
def test_interpolate_nan_linear(): """Test deprecated interpolate_nans function.""" x = np.linspace(0, 20, 15) y = 5 * x + 3 nan_indexes = [1, 5, 11, 12] y_with_nan = y.copy() y_with_nan[nan_indexes] = np.nan with pytest.warns(MetpyDeprecationWarning): assert_array_almost_equal(y, interpolate_nans(x, y_with_nan), 2)
def test_interpolate_nan_invalid(): """Test log interpolation with invalid parameter.""" x = np.logspace(1, 5, 15) y = 5 * np.log(x) + 3 with pytest.raises(ValueError): interpolate_nans(x, y, kind='loog')