Skip to content

Commit

Permalink
Merge pull request #208 from cgahr/develop
Browse files Browse the repository at this point in the history
fix #200: raise TypeError on unused kwargs
  • Loading branch information
roxyboy committed Jul 3, 2024
2 parents 60e37a4 + caae000 commit 9ac46f9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
9 changes: 8 additions & 1 deletion xrft/tests/test_xrft.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import dask.array as dsar

import scipy.signal as sps
import scipy.linalg as spl

import pytest
import numpy.testing as npt
Expand Down Expand Up @@ -202,6 +201,14 @@ def test_fft_4d(self):
np.fft.fftn(da_prime),
)

def test_fft_raises_on_unused_kwarg(self):
with pytest.raises(TypeError):
xrft.fft(None, dims=1)

def test_ifft_raises_on_unused_kwarg(self):
with pytest.raises(TypeError):
xrft.fft(None, dims=1)


class TestfftReal(object):
def test_fft_real_1d(self, test_data_1d):
Expand Down
15 changes: 6 additions & 9 deletions xrft/xrft.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import warnings
import operator
import sys
import functools as ft
from functools import reduce

import numpy as np
Expand All @@ -12,7 +10,6 @@
from dask import delayed

import scipy.signal as sps
import scipy.linalg as spl

from .detrend import detrend as _detrend
from pandas.api.types import is_numeric_dtype, is_datetime64_any_dtype
Expand Down Expand Up @@ -319,7 +316,7 @@ def fft(
true_amplitude=True,
chunks_to_segments=False,
prefix="freq_",
**kwargs,
real=None,
):
"""
Perform discrete Fourier transform of xarray data-array `da` along the
Expand Down Expand Up @@ -376,8 +373,8 @@ def fft(
if isinstance(dim, str):
dim = [dim]

if "real" in kwargs:
real_dim = kwargs.get("real")
if real is not None:
real_dim = real
warnings.warn(_real_flag_warning, FutureWarning)

if real_dim is not None:
Expand Down Expand Up @@ -490,7 +487,7 @@ def ifft(
chunks_to_segments=False,
prefix="freq_",
lag=None,
**kwargs,
real=None,
):
"""
Perform inverse discrete Fourier transform of xarray data-array `daft` along the
Expand Down Expand Up @@ -543,8 +540,8 @@ def ifft(
if isinstance(dim, str):
dim = [dim]

if "real" in kwargs:
real_dim = kwargs.get("real")
if real is not None:
real_dim = real
warnings.warn(_real_flag_warning, FutureWarning)

if real_dim is not None:
Expand Down

0 comments on commit 9ac46f9

Please sign in to comment.