From 0b3036659ab61ddeff025cd8775435edfcf82106 Mon Sep 17 00:00:00 2001 From: akeeste Date: Thu, 17 Oct 2024 15:10:01 -0500 Subject: [PATCH] black formatting --- mhkit/tests/wave/test_resource_metrics.py | 2 +- mhkit/tests/wave/test_resource_spectrum.py | 2 +- mhkit/wave/resource.py | 10 ++++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/mhkit/tests/wave/test_resource_metrics.py b/mhkit/tests/wave/test_resource_metrics.py index b1266fff..3df52fcd 100644 --- a/mhkit/tests/wave/test_resource_metrics.py +++ b/mhkit/tests/wave/test_resource_metrics.py @@ -122,7 +122,7 @@ def test_wave_length(self): for k in [k_int]: l_calculated = wave.resource.wave_length(k) self.assertTrue(np.all(2.0 * np.pi / k == l_calculated)) - + for k in [k_array, k_float, k_df, k_series]: l_calculated = wave.resource.wave_length(k) self.assertTrue(np.all(2.0 * np.pi / k == l_calculated)) diff --git a/mhkit/tests/wave/test_resource_spectrum.py b/mhkit/tests/wave/test_resource_spectrum.py index 39015c55..d2c0f235 100644 --- a/mhkit/tests/wave/test_resource_spectrum.py +++ b/mhkit/tests/wave/test_resource_spectrum.py @@ -168,7 +168,7 @@ def test_user_spectrum_without_frequency_index_name_defined(self): expected_magnitude = [-0.983917, 1.274248, -2.129812] - assert_allclose(result.values[:,0], expected_magnitude, atol=1e-6) + assert_allclose(result.values[:, 0], expected_magnitude, atol=1e-6) def test_ifft_sum_of_sines(self): S = wave.resource.jonswap_spectrum(self.f, self.Tp, self.Hs) diff --git a/mhkit/wave/resource.py b/mhkit/wave/resource.py index 5ce55730..a507792a 100644 --- a/mhkit/wave/resource.py +++ b/mhkit/wave/resource.py @@ -53,7 +53,7 @@ def elevation_spectrum( # TODO: Add confidence intervals, equal energy frequency spacing, and NDBC # frequency spacing # TODO: may need to raise an error for the length of nnft- signal.welch breaks when nfft is too short - eta = convert_to_dataset(eta,"eta") + eta = convert_to_dataset(eta, "eta") if not isinstance(sample_rate, (float, int)): raise TypeError( f"sample_rate must be of type int or float. Got: {type(sample_rate)}" @@ -287,11 +287,11 @@ def surface_elevation( Returns --------- eta: pandas DataFrame or xarray Dataset - Wave surface elevation [m] indexed by time [s]. Type depends on + Wave surface elevation [m] indexed by time [s]. Type depends on number of variables in eta and value of the to_pandas flag. """ - S = convert_to_dataset(S,"S") + S = convert_to_dataset(S, "S") time_index = to_numeric_array(time_index, "time_index") if not isinstance(seed, (type(None), int)): raise TypeError(f"If specified, seed must be of type int. Got: {type(seed)}") @@ -373,7 +373,9 @@ def surface_elevation( if phases is None: np.random.seed(seed) phase = xr.DataArray( - data=2 * np.pi * np.random.random_sample(S_subset[frequency_dimension].shape), + data=2 + * np.pi + * np.random.random_sample(S_subset[frequency_dimension].shape), dims=frequency_dimension, coords={frequency_dimension: f}, )