(x, smooth_window)
return np.convolve(x, moving_average.conv_filter, mode='valid')
Returns a smoothed version of x.

  This smoothes the x array according to the smooth_window parameter.

  Args:
    x: The array to smooth.
    smooth_window: An integer that defines the neighborhood to be used in
      smoothing.
Returns a smoothed version of x.
Returns a smoothed version of x .
def moving_average(x, smooth_window):
  """Returns a smoothed version of x.

  This smoothes the x array according to the smooth_window parameter.

  Args:
    x: The array to smooth.
    smooth_window: An integer that defines the neighborhood to be used in
      smoothing.
  """
  conv_filter = getattr(moving_average, 'conv_filter', None)
  if conv_filter is None or (moving_average.conv_filter_size != smooth_window):
    moving_average.conv_filter = np.ones((smooth_window,)) / smooth_window
    moving_average.conv_filter_size = smooth_window
  # if smooth_window is even, pad accordingly to keep stream size
  x = np.pad(x, (smooth_window // 2, smooth_window - 1 - (smooth_window // 2)),
             'reflect')
  return np.convolve(x, moving_average.conv_filter, mode='valid')
def moving_average ( x , smooth_window ) : conv_filter = getattr ( moving_average , 'conv_filter' , None ) if conv_filter is None or ( moving_average . conv_filter_size != smooth_window ) : moving_average . conv_filter = np . ones ( ( smooth_window , ) ) / smooth_window moving_average . conv_filter_size = smooth_window # if smooth_window is even, pad accordingly to keep stream size x = np . pad ( x , ( smooth_window // 2 , smooth_window - 1 - ( smooth_window // 2 ) ) , 'reflect' ) return np . convolve ( x , moving_average . conv_filter , mode = 'valid' )