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
Owner

What was built

Add a median(values) function to src/calculator.py returning the median, raising ValueError on an empty sequence. Follow the conventions in CLAUDE.md.

Acceptance criteria

  • The ticket objective is satisfied: Add a median function to the calculator

Commits

Commit Summary Node
df8d292a6e61 test(sveta): Write tests for median function 341a13e1a6b0
7e7645659968 feat(nadia): Implement median function in src/calculator.py d0a2754c13cc

Run

Cost: 0.0010 USD · Nodes: 8 · Verification: make verify

Closes #13

## What was built Add a `median(values)` function to src/calculator.py returning the median, raising ValueError on an empty sequence. Follow the conventions in CLAUDE.md. ## Acceptance criteria - The ticket objective is satisfied: Add a median function to the calculator ## Commits | Commit | Summary | Node | |---|---|---| | `df8d292a6e61` | test(sveta): Write tests for median function | `341a13e1a6b0` | | `7e7645659968` | feat(nadia): Implement median function in src/calculator.py | `d0a2754c13cc` | ## Run Cost: 0.0010 USD · Nodes: 8 · Verification: make verify Closes #13
typosaurus added 2 commits 2026-07-26 17:11:02 +02:00
**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
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
typosaurus force-pushed typosaurus/13-add-a-median-function-to-the-calculator from b78ecc077e to a80acb36c3 2026-07-26 22:11:38 +02:00 Compare
typosaurus self-assigned this 2026-07-26 22:20:54 +02:00
typosaurus force-pushed typosaurus/13-add-a-median-function-to-the-calculator from a80acb36c3 to df8d292a6e 2026-07-26 23:16:24 +02:00 Compare
typosaurus merged commit 5781484f23 into main 2026-07-27 00:14:46 +02:00
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: typosaurus/typosaurus-sandbox#14
No description provided.