Skip to content

Commit

Permalink
fix: raise error correctly in resample funcs
Browse files Browse the repository at this point in the history
  • Loading branch information
fhchl committed Feb 27, 2019
1 parent 5cd3a89 commit fb760db
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions response.py
Original file line number Diff line number Diff line change
Expand Up @@ -752,16 +752,16 @@ def lowpass_by_frequency_domain_window(self, fstart, fstop):
h = lowpass_by_frequency_domain_window(self.fs, self.in_time, fstart, fstop)
return self.from_time(self.fs, h)

def resample(self, fs_new, normalize="keep_gain", window=None):
def resample(self, fs_new, normalize="same_gain", window=None):
"""Resample using Fourier method.
Parameters
----------
fs_new : int
New sample rate
normalize : str, optional
If 'keep_gain', normalize such that the gain is the same
as the original signal. If 'keep_amplitudes', amplitudes will be preserved.
If 'same_gain', normalize such that the gain is the same
as the original signal. If 'same_amplitude', amplitudes will be preserved.
window : None, optional
Passed to scipy.signal.resample.
Expand Down Expand Up @@ -795,7 +795,9 @@ def resample(self, fs_new, normalize="keep_gain", window=None):
elif normalize == "same_amplitude":
pass
else:
ValueError("Expected 'same_gain' or 'same_amplitude, got %s" % (normalize,))
raise ValueError(
"Expected 'same_gain' or 'same_amplitude', got %s" % (normalize,)
)

return self.from_time(fs_new, h_new)

Expand All @@ -807,8 +809,8 @@ def resample_poly(self, fs_new, normalize="same_gain", window=("kaiser", 5.0)):
fs_new : int
New sample rate
normalize : str, optional
If 'keep_gain', normalize such that the gain is the same
as the original signal. If 'keep_amplitudes', amplitudes will be preserved.
If 'same_gain', normalize such that the gain is the same
as the original signal. If 'same_amplitude', amplitudes will be preserved.
window : None, optional
Passed to scipy.signal.resample_poly.
Expand All @@ -835,7 +837,9 @@ def resample_poly(self, fs_new, normalize="same_gain", window=("kaiser", 5.0)):
elif normalize == "same_amplitude":
pass
else:
ValueError("Expected 'same_gain' or 'same_amplitude, got %s" % (normalize,))
raise ValueError(
"Expected 'same_gain' or 'same_amplitude', got %s" % (normalize,)
)

return self.from_time(fs_new, h_new)

Expand Down

0 comments on commit fb760db

Please sign in to comment.