Commit 57bd2164 authored by lucas_miranda's avatar lucas_miranda
Browse files

Added .gitlab-ci.yml for Continuous integration

parent 799660ad
...@@ -225,12 +225,12 @@ def smooth_boolean_array(a: np.array) -> np.array: ...@@ -225,12 +225,12 @@ def smooth_boolean_array(a: np.array) -> np.array:
def rolling_window(a: np.array, window_size: int, window_step: int) -> np.array: def rolling_window(a: np.array, window_size: int, window_step: int) -> np.array:
"""Returns a 3D numpy.array with a sliding-window extra dimension """Returns a 3D numpy.array with a sliding-window extra dimension
Parameters: Parameters:
- a (2D np.array): N (instances) * m (features) shape - a (2D np.array): N (instances) * m (features) shape
Returns: Returns:
- rolled_a (3D np.array): - rolled_a (3D np.array):
N (sliding window instances) * l (sliding window size) * m (features)""" N (sliding window instances) * l (sliding window size) * m (features)"""
shape = (a.shape[0] - window_size + 1, window_size) + a.shape[1:] shape = (a.shape[0] - window_size + 1, window_size) + a.shape[1:]
strides = (a.strides[0],) + a.strides strides = (a.strides[0],) + a.strides
...@@ -241,14 +241,24 @@ def rolling_window(a: np.array, window_size: int, window_step: int) -> np.array: ...@@ -241,14 +241,24 @@ def rolling_window(a: np.array, window_size: int, window_step: int) -> np.array:
@jit @jit
def smooth_mult_trajectory(series, alpha=0.15): def smooth_mult_trajectory(series: np.array, alpha: float = 0.15) -> np.array:
"""smooths a trajectory using exponentially weighted averages""" """Returns a smooths a trajectory using exponentially weighted averages
Parameters:
- series (np.array): 2D trajectory array with N (instances) * m (features)
- alpha (float): 0 <= alpha <= 1; indicates the weight assigned to the current observation.
higher (alpha~1) indicates less smoothing; lower indicates more (alpha~0)
Returns:
- smoothed_series (np.array): smoothed version of the input, with equal shape"""
result = [series[0]] result = [series[0]]
for n in range(len(series)): for n in range(len(series)):
result.append(alpha * series[n] + (1 - alpha) * result[n - 1]) result.append(alpha * series[n] + (1 - alpha) * result[n - 1])
return np.array(result) smoothed_series = np.array(result)
return smoothed_series
##### IMAGE/VIDEO PROCESSING FUNCTIONS ##### ##### IMAGE/VIDEO PROCESSING FUNCTIONS #####
......
...@@ -220,5 +220,5 @@ def test_rolling_window(a, window): ...@@ -220,5 +220,5 @@ def test_rolling_window(a, window):
rolled_shape = rolling_window(a, window_size, window_step).shape rolled_shape = rolling_window(a, window_size, window_step).shape
assert len(rolled_shape) == a.shape + 1 assert len(rolled_shape) == len(a.shape) + 1
assert rolled_shape[1] == window_size assert rolled_shape[1] == window_size
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment