WWindowRidge
Product

Product features · Sliding-window maxima

01

Check repeated maxima, negative values and width boundaries, rejecting non-finite values and widths outside the input length.

01

Connection

Base URL, credentials and a reachable server.

02

Selection

A model available through the configured endpoint.

03

Capabilities

Context limits and tool support are determined by the model and server.

Sliding-window maxima

● ● ●WindowRidge●
A concrete starting point · Sliding-window maxima ×
from collections import deque
from math import isfinite
def window_max(values, width):
    if type(width) is not int or not 1 <= width <= len(values):
        raise ValueError("width")
    if not all(map(isfinite, values)): raise ValueError("finite values")
    queue, result = deque(), []
    for i, value in enumerate(values):
        while queue and queue[0] <= i - width: queue.popleft()
        while queue and values[queue[-1]] <= value: queue.pop()
        queue.append(i)
        if i >= width - 1: result.append(values[queue[0]])
    return result
✳Find the maximum in each complete fixed-width numeric window.
✓ ChangesReview before applying ↗
Illustrative workspace
AI coding workspace

Your next change starts here.

Get the Windows app ↗