feat: Add a median function to the calculator #14

Merged
typosaurus merged 2 commits from typosaurus/13-add-a-median-function-to-the-calculator into main 2026-07-27 00:14:46 +02:00

2 Commits

Author SHA1 Message Date
df8d292a6e test(sveta): Write tests for median function
Outcome: done

Changed: tests/test_calculator.py:3, tests/test_calculator.py:68-90

Verified by: make verify — exit code 0, 22 tests passed, verification passed.

Findings:
- tests/test_calculator.py:3 — `median` imported alongside `clamp`.
- tests/test_calculator.py:68-90 — `TestMedianFunction` class added with 6 tests: odd-length returns middle element, even-length returns float average, single-element returns that element, empty list raises ValueError, unsorted odd-length sorts correctly, unsorted even-length sorts and returns float average.
- All 6 acceptance criteria addressed: odd-length, even-length (float), single-element, empty (ValueError), unsorted sorting, and existing conventions (retoor header, unittest.TestCase, full type annotations).

Open: none

Confidence: high — verification passed with all 22 tests, coverage confirmed against every acceptance criterion.

Typosaurus-Run: 529efb295dd94e799a5e47a9ef0c6c16
Typosaurus-Node: 341a13e1a6b04e838cc1ff6d643aab85
Typosaurus-Agent: @sveta
Refs: #13
2026-07-26 21:15:58 +00:00
7e76456599 feat(nadia): Implement median function in src/calculator.py
**Outcome:** done

**Changed:** src/calculator.py:28-34

**Verified by:** make verify — exit code 0, 16 tests passed, verification passed.

**Findings:**
- src/calculator.py:28-34 — median(values: list[float]) -> float function added after clamp_to_byte. Full type annotations, no comments/docstrings. Raises ValueError on empty sequence. Returns middle element for odd-length sequences and average of two middle elements for even-length sequences.

**Open:** Tests for the new function need to be written by @sveta.

**Confidence:** high

Typosaurus-Run: 529efb295dd94e799a5e47a9ef0c6c16
Typosaurus-Node: d0a2754c13cc4742bb46790341416bd6
Typosaurus-Agent: @nadia
Refs: #13
2026-07-26 21:14:45 +00:00