this code is at the bottom of the file
`if name == "main":
# Example usage
data = np.array([20, 1, 2, 3, 4, 5, 20, 6, 7, 8, 9, 10, 25])
print(out_of_iqr_window(data))
# rolling windows of size 5: shape -> (len(data)-4, 5)
window_size = 5
edge_idx = window_size // 2
windows = np.lib.stride_tricks.sliding_window_view(data, window_size)
# outlier flag for each 5-value window (checks center element of each window)
# center points (indices 2..-3)
window_flags = np.apply_along_axis(out_of_iqr_window, 1, windows)
edge_window_size = window_size + window_size // 2 - 1
start_windows = np.lib.stride_tricks.sliding_window_view(
data[:edge_window_size], window_size
)
start_window_flags = np.apply_along_axis(
out_of_iqr_window,
1,
start_windows,
position="first", # passed to out_of_iqr_window
)
end_windows = np.lib.stride_tricks.sliding_window_view(
data[-(edge_window_size):], window_size
)
end_window_flags = np.apply_along_axis(
out_of_iqr_window,
1,
end_windows,
position="last", # passed to out_of_iqr_window
)
print("center windows flags:", window_flags)
print("start edge windows:", start_windows)
print("start edge window flags:", start_window_flags)
print("end edge windows:", end_windows)
print("end edge window flags:", end_window_flags)
# optional: align back to original array length (center indices only)
flags = np.full(data.shape, False)
flags[:edge_idx] = start_window_flags # [:edge_idx]
flags[edge_idx:-edge_idx] = window_flags
flags[-edge_idx:] = end_window_flags
print("windows:\n", windows)
print("window_flags:", window_flags)
print("aligned flags:", flags)
mask = detect_outliers_iqr(data, window_size=5)
print("final mask:", mask)
assert (mask == flags).all()`
this code is at the bottom of the file
`if name == "main":
# Example usage
data = np.array([20, 1, 2, 3, 4, 5, 20, 6, 7, 8, 9, 10, 25])
print(out_of_iqr_window(data))