mirror of
https://github.com/dotnet/skills.git
synced 2026-09-20 09:49:54 +08:00
5a06b20cc9
* Support classic .NET test projects Teach dotnet-test skills and agents to preserve non-SDK projects, packages.config dependencies, explicit compile registration, legacy runners, and version-compatible MSTest APIs. Add regression evals for generation, execution, coverage, and authoring. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: fdfec89f-b610-479c-a6c7-c2936b300e68 * Address classic test fixture review Tighten the MSTest version grader, make the runner fixture assertion behavioral, and use nameof for the guarded parameter. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: fdfec89f-b610-479c-a6c7-c2936b300e68 --------- Copilot-Session: fdfec89f-b610-479c-a6c7-c2936b300e68
25 lines
731 B
Python
25 lines
731 B
Python
from __future__ import annotations
|
|
|
|
|
|
class RateWindow:
|
|
def __init__(self, capacity: int) -> None:
|
|
if capacity <= 0:
|
|
raise ValueError("capacity must be positive")
|
|
self._capacity = capacity
|
|
self._samples: list[float] = []
|
|
|
|
def add(self, value: float) -> None:
|
|
self._samples.append(value)
|
|
if len(self._samples) > self._capacity:
|
|
self._samples.pop(0)
|
|
|
|
def average(self) -> float:
|
|
if not self._samples:
|
|
raise RuntimeError("window is empty")
|
|
return sum(self._samples) / len(self._samples)
|
|
|
|
def peak(self) -> float:
|
|
if not self._samples:
|
|
raise RuntimeError("window is empty")
|
|
return max(self._samples)
|