Skip to content

Commit

Permalink
automatically coerce coerce coefficients for SV smoothing
Browse files Browse the repository at this point in the history
  • Loading branch information
newville committed Jul 10, 2024
1 parent 10512e1 commit 82fb234
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions larch/math/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,11 +409,11 @@ def savitzky_golay(y, window_size, order, deriv=0):
window_size = abs(int(window_size))
order = abs(int(order))
except ValueError:
raise ValueError("window_size and order have to be of type int")
if window_size % 2 != 1 or window_size < 1:
raise TypeError("window_size size must be a positive odd number")
raise ValueError("window_size and order must be integers")
if window_size < order + 2:
raise TypeError("window_size is too small for the polynomials order")
window_size = order + 3
if window_size % 2 != 1 or window_size < 1:
window_size = window_size + 1
order_range = range(order+1)
half_window = (window_size -1) // 2
# precompute coefficients
Expand Down

0 comments on commit 82fb234

Please sign in to comment.