Skip to content

Tighten exercise contracts after a curriculum review - #19

Merged
danhalligan merged 1 commit into
mainfrom
improve-exercise-contracts
Nov 4, 2026
Merged

danhalligan merged 1 commit into
mainfrom
improve-exercise-contracts

Conversation

@danhalligan

Copy link
Copy Markdown
Owner

Follows a review of the exercises against the aims in CONTRIBUTING.md: avoid repetition, mechanical work with no payoff, hidden contracts and ambiguity.

Changes

Weasel breeds from the best current offspring

  • Each generation now breeds from the best offspring of the previous one (discrete generations), rather than from the best candidate ever seen.
  • match_history is each parent's score and can fall; candidate is the final parent. The README, docstring and notebook say so, and the "last stubborn letter" investigation now describes the parent's score.
  • Removed the "history never decreases" test and added test_each_generation_breeds_from_the_latest_offspring.

Known unknowns: less repeated bookkeeping

  • New exercises/known_unknowns/simulation.py provides coverage_study and plot_coverage, with tests in tests/test_known_unknowns_simulation.py. They take an explicit rng.
  • Sections 4 and 5 of the notebook and README now ask learners only for the interval methods, the true values and the interpretation.

Remove validation-only tests
CONTRIBUTING.md says not to test negative sizes, out-of-range probabilities or empty/malformed inputs unless that is the point. I removed those tests, and the matching "Raise ValueError…" lines in the stubs, from Known unknowns, Weasel, Wordsmith, Word ladder, Sudoku, Sequence alignment, Fitting a mixture, Try, try again and Titanic. Where the failure is the lesson (penguin and plate joins, UnknownSoundError, the optimiser failure, unknown classifier arguments) the tests stay.

Fix

  • The Titanic notebook told learners to run uv run pytest exercises/data_analysis/titanic/ -q; the path is now exercises/titanic_disaster/.

Checks

  • uv run ruff check . and uv run ruff format --check . pass.
  • uv run pytest --collect-only collects all tests.
  • uv run pytest tests -q passes (278 passed, 2 skipped).
  • Exercise tests are expected to fail on the starter branch where stubs are unfinished.

- Weasel: breed each generation from the best current offspring (discrete
  generations). match_history is now each parent's score and can fall, and
  candidate is the final parent. The README, docstrings, notebook and tests
  say so, and a new test pins down the behaviour.
- Known unknowns: move the coverage-study helpers into simulation.py (with
  tests) so learners write only the interval methods and the interpretation.
  Helpers take an explicit rng.
- Remove tests and stub requirements that only checked input validation
  (negative sizes, out-of-range probabilities, empty or malformed inputs),
  as CONTRIBUTING.md asks, in Known unknowns, Weasel, Wordsmith, Word
  ladder, Sudoku, Sequence alignment, Fitting a mixture, Try, try again
  and Titanic.
- Titanic notebook: fix the focused test command to
  exercises/titanic_disaster/.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@danhalligan
danhalligan merged commit d58f910 into main Nov 4, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant