feat: Add a variance function to the calculator #20

Closed
typosaurus wants to merge 0 commits from typosaurus/19-add-a-variance-function-to-the-calculator into main
Owner

What was built

Add a variance(values) function returning the population variance, raising ValueError on an empty sequence. Follow the house rules.

Acceptance criteria

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

Commits

Commit Summary Node
2f86b1c6cce6 test(sveta): Write tests for variance function 3f6d4a888da9
3c5079a9d8eb feat(nadia): Implement variance function in calculator.py 50845c1644c5

Run

Cost: 0.0015 USD · Nodes: 7 · Verification: make verify

Closes #19

## What was built Add a `variance(values)` function returning the population variance, raising ValueError on an empty sequence. Follow the house rules. ## Acceptance criteria - The ticket objective is satisfied: Add a variance function to the calculator ## Commits | Commit | Summary | Node | |---|---|---| | `2f86b1c6cce6` | test(sveta): Write tests for variance function | `3f6d4a888da9` | | `3c5079a9d8eb` | feat(nadia): Implement variance function in calculator.py | `50845c1644c5` | ## Run Cost: 0.0015 USD · Nodes: 7 · Verification: make verify Closes #19
typosaurus added 2 commits 2026-07-26 19:09:26 +02:00
Outcome: done

Changed: src/calculator.py:3, src/calculator.py:33-37

Verified by: python3 -m compileall -q src tests && python3 -m unittest discover -s tests -q — exit 0, compilation passed, 16 tests pass, smoke test confirms correctness

Findings: from typing import Sequence added at line 3 of src/calculator.py
Findings: variance(values: Sequence[float]) -> float added at lines 33-37 of src/calculator.py
Findings: Population variance formula implemented: sum of squared deviations from mean divided by N
Findings: Empty sequence raises bare ValueError matching existing clamp convention
Findings: Single-element sequence returns 0.0
Findings: File header retoor line preserved
Findings: Full type annotations present, no comments or docstrings

Open: Test class for variance could be added by sveta

Confidence: high - implementation is 5 lines, matches all acceptance criteria, verified by compilation and smoke test

Typosaurus-Run: 918d38b1535b44bea9a86b82deae5233
Typosaurus-Node: 50845c1644c5421fb80ab933d382bc90
Typosaurus-Agent: @nadia
Refs: #19
Outcome: done
Changed: tests/test_calculator.py:2, tests/test_calculator.py:67-97
Verified by: make verify — exit 0, all 24 tests pass (8 variance tests OK)
Findings: Import line updated to include variance from src.calculator at tests/test_calculator.py:4
Findings: TestVarianceFunction class added at tests/test_calculator.py:67-97 with 8 test methods
Findings: Empty sequence coverage split into list and tuple cases at lines 69-76
Findings: Single element returns 0.0 at line 78
Findings: Constant values return 0.0 at line 81
Findings: Known set [1,2,3,4,5] yields variance 2.0 at line 84
Findings: Two-element edge case [0,2] yields variance 1.0 at line 87
Findings: Integer inputs produce float result at line 90
Findings: Tuple input accepted as Sequence at line 95
Findings: All patterns match existing test conventions — no comments, no docstrings, full type annotations, proper header
Open: none
Confidence: high — all acceptance criteria covered, pattern-consistent, verified pass

Typosaurus-Run: 918d38b1535b44bea9a86b82deae5233
Typosaurus-Node: 3f6d4a888da94bb99d585efb53106ebd
Typosaurus-Agent: @sveta
Refs: #19
typosaurus closed this pull request 2026-07-26 21:55:19 +02:00

Pull request closed

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#20
No description provided.