Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
- run: uv sync --dev
- uses: actions/checkout@v5
- uses: astral-sh/setup-uv@v7
- run: uv sync --extra dev --group test
- run: uv run ruff check src tests
- run: uv run ruff format --check src tests

Expand All @@ -22,17 +22,17 @@ jobs:
matrix:
python-version: ["3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
- uses: actions/checkout@v5
- uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}
- run: uv sync --dev
- run: uv sync --extra dev --group test
- run: uv run pytest tests/ -v

typecheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
- run: uv sync --dev
- uses: actions/checkout@v5
- uses: astral-sh/setup-uv@v7
- run: uv sync --extra dev --group test
- run: uv run mypy src
8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ Repository = "https://github.com/finite-sample/streamcal"
dev = ["pytest", "ruff", "mypy"]
docs = ["sphinx", "furo", "myst-parser"]

[dependency-groups]
test = [
"pytest",
# Monte Carlo test machinery. A dependency-group, not an extra: PyPI rejects
# direct URL references in published project metadata.
"simcheck @ git+https://github.com/finite-sample/simcheck",
]

[tool.hatch.build.targets.wheel]
packages = ["src/streamcal"]

Expand Down
14 changes: 9 additions & 5 deletions src/streamcal/calibrators.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ def _pav(self, y: NDArray[np.floating[Any]]) -> NDArray[np.floating[Any]]:

def calibrate(self, p_raw: NDArray[np.floating[Any]]) -> NDArray[np.floating[Any]]:
"""Apply monotonic calibration via interpolation."""
return np.interp(p_raw, self.bucket_centers, self.calibration_values)
return np.interp( # type: ignore[no-any-return]
p_raw, self.bucket_centers, self.calibration_values
)

def update(
self, p_raw: NDArray[np.floating[Any]], y: NDArray[np.floating[Any]]
Expand Down Expand Up @@ -144,7 +146,9 @@ def reset(self) -> None:

def calibrate(self, p_raw: NDArray[np.floating[Any]]) -> NDArray[np.floating[Any]]:
"""Apply calibration via interpolation."""
return np.interp(p_raw, self.bucket_centers, self.calibration_values)
return np.interp( # type: ignore[no-any-return]
p_raw, self.bucket_centers, self.calibration_values
)

def _apply_nearly_isotonic(
self, rates: NDArray[np.floating[Any]]
Expand Down Expand Up @@ -184,9 +188,9 @@ def update(
self.ema_rates[b] = batch_rate
self.has_seen[b] = True
else:
self.ema_rates[b] = (
1 - self.alpha
) * self.ema_rates[b] + self.alpha * batch_rate
self.ema_rates[b] = (1 - self.alpha) * self.ema_rates[
b
] + self.alpha * batch_rate

self.calibration_values = self._apply_nearly_isotonic(self.ema_rates)

Expand Down
Loading
Loading