Skip to content

Commit

Permalink
run code-style checks
Browse files Browse the repository at this point in the history
  • Loading branch information
paigem committed Aug 27, 2021
1 parent 4bffa9c commit 9f79f07
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 4 additions & 6 deletions xrft/tests/test_xrft.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,6 @@ def test_window_single_dim():
ps.load()




class TestSpectrum(object):
@pytest.mark.parametrize("dim", ["t", "time"])
@pytest.mark.parametrize("window_correction", [True, False])
Expand Down Expand Up @@ -1309,6 +1307,7 @@ def test_reversed_coordinates():
xrft.dft(s, dim="x", true_phase=True), xrft.dft(s2, dim="x", true_phase=True)
)


def test_nondim_coords():
"""Error should be raised if there are non-dimensional coordinates attached to the dimension(s) over which the FFT is being taken"""
N = 16
Expand All @@ -1319,12 +1318,11 @@ def test_nondim_coords():
"time": np.array(["2019-04-18", "2019-04-19"], dtype="datetime64"),
"x": range(N),
"y": range(N),
"x_nondim":("x",np.arange(N))
"x_nondim": ("x", np.arange(N)),
},
)

with pytest.raises(ValueError):
xrft.power_spectrum(da)

xrft.power_spectrum(da,dim=["time","y"])

xrft.power_spectrum(da, dim=["time", "y"])
4 changes: 3 additions & 1 deletion xrft/xrft.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,9 @@ def fft(

# raise error if there are multiple coordinates attached to the dimension(s) over which the FFT is taken
for d in dim:
bad_coords = [cname for cname in da.coords if cname != dim and dim in da[cname].dims]
bad_coords = [
cname for cname in da.coords if cname != dim and dim in da[cname].dims
]
if bad_coords:
raise ValueError(
f"The input array contains coordinate variable(s) ({bad_coords}) whose dims include the transform dimension(s) `{dim}`. "
Expand Down

0 comments on commit 9f79f07

Please sign in to comment.