diff --git a/src/waveresponse/_core.py b/src/waveresponse/_core.py index 8a526cc..4f89d4c 100644 --- a/src/waveresponse/_core.py +++ b/src/waveresponse/_core.py @@ -598,7 +598,7 @@ def rotate(self, angle, degrees=False): dirs_new = _robust_modulus(new._dirs - angle, 2.0 * np.pi) new._dirs, new._vals = _sort(dirs_new, new._vals) return new - + def _interpolate_function(self, complex_convert="rectangular", **kw): """ Interpolation function based on ``scipy.interpolate.interp2d``. @@ -606,7 +606,7 @@ def _interpolate_function(self, complex_convert="rectangular", **kw): xp = np.concatenate( (self._dirs[-1:] - 2 * np.pi, self._dirs, self._dirs[:1] + 2.0 * np.pi) ) - + yp = self._freq zp = np.concatenate( ( @@ -616,7 +616,7 @@ def _interpolate_function(self, complex_convert="rectangular", **kw): ), axis=1, ) - + if np.all(np.isreal(zp)): return RGI((xp, yp), zp.T, **kw) elif complex_convert.lower() == "polar": @@ -648,7 +648,6 @@ def interpolate( complex_convert="rectangular", fill_value=0.0, ): - freq = np.asarray_chkfinite(freq).reshape(-1) dirs = np.asarray_chkfinite(dirs).reshape(-1) @@ -662,11 +661,14 @@ def interpolate( self._check_dirs(dirs) interp_fun = self._interpolate_function( - complex_convert=complex_convert, method='linear', bounds_error=False, fill_value = fill_value + complex_convert=complex_convert, + method="linear", + bounds_error=False, + fill_value=fill_value, ) - xxnew, yynew = np.meshgrid(dirs, freq, indexing='ij', sparse=True) + xxnew, yynew = np.meshgrid(dirs, freq, indexing="ij", sparse=True) return interp_fun((xxnew, yynew)).T - + def reshape( self, freq, diff --git a/src/waveresponse/_standardized1d.py b/src/waveresponse/_standardized1d.py index 55a0dcf..6063617 100644 --- a/src/waveresponse/_standardized1d.py +++ b/src/waveresponse/_standardized1d.py @@ -556,7 +556,9 @@ def _spectrum(self, omega, hs, tp): A_secondary = (3.26 / 16.0) * hs_secondary**2 * omega_p_secondary**3 B_secondary = omega_p_secondary**4 - spectrum_secondary = A_secondary / omega**4 * np.exp(-B_secondary / omega**4) + spectrum_secondary = ( + A_secondary / omega**4 * np.exp(-B_secondary / omega**4) + ) return spectrum_primary + spectrum_secondary diff --git a/tests/test_core.py b/tests/test_core.py index 7deff64..a7a2d59 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -1367,7 +1367,7 @@ def test_interpolate(self): vals_expect = np.array([[a * x_i + b * y_i for x_i in x] for y_i in y]) vals_out = grid.interpolate(y, x, freq_hz=True, degrees=True) - + np.testing.assert_array_almost_equal(vals_out, vals_expect) def test_interpolate2(self): @@ -3360,7 +3360,9 @@ def test_moment_m2_rads(self): m_out = spectrum.moment(2, freq_hz=False) - m_expect = (1.0 / 3.0) * (0.0 - 360.0) * (f0**3 - f1**3) * (2.0 * np.pi) ** 2 + m_expect = ( + (1.0 / 3.0) * (0.0 - 360.0) * (f0**3 - f1**3) * (2.0 * np.pi) ** 2 + ) # not exactly same due to error in trapezoid for higher order functions assert m_out == pytest.approx(m_expect, rel=0.1)