Skip to content

Commit

Permalink
black formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
akeeste committed Oct 17, 2024
1 parent d13bb22 commit 0b30366
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion mhkit/tests/wave/test_resource_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion mhkit/tests/wave/test_resource_spectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 6 additions & 4 deletions mhkit/wave/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)}"
Expand Down Expand Up @@ -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)}")
Expand Down Expand Up @@ -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},
)
Expand Down

0 comments on commit 0b30366

Please sign in to comment.