kangwonlee / kangwonlee/nmisp

Pedagogy: add testing & debugging notebook under 06_python_advanced/

Open
#392 0 comments 0 reactions 0 assignees View on GitHub
pedagogy
Dominant language
Jupyter Notebook
Stars
12
Forks
76
PR merge metrics
No merged PRs in 30d

Description

## Goal

NMISP currently teaches `assert` and basic error handling inside the long `00_introduction/20_python_review.ipynb`, but never makes testing and debugging an explicit topic. Every later chapter (root-finding, interpolation, ODE) writes iterative numerical code where bugs are subtle (off-by-one in iterations, missing convergence check, sign error). Students hit these constantly without an explicit framework for diagnosing them.

## Scope

Create `06_python_advanced/10_testing_debugging.ipynb` covering:

- `assert` for invariants and basic test functions
- Error taxonomy: syntax errors, runtime errors (e.g. `ZeroDivisionError`, `IndexError`), and logical errors (code runs but produces wrong answers)
- Reading tracebacks
- Quick intro to `pdb` / `breakpoint()` (optional section)
- 3 deliberately-broken numerical functions for the student to fix:
- Bisection with an off-by-one halving bug
- Newton-Raphson missing the convergence check
- A summation routine with a precision-related bug (foreshadows `10_floating_point.ipynb`)

## Why

- Debugging is the dominant time sink for learners writing iterative numerical code.
- Without an explicit notebook, students treat each bug as a one-off frustration rather than a class of problem.
- Sets up vocabulary (\"this is a logical error, not a runtime error\") used in later chapters.

## Acceptance

- [ ] Notebook executes end-to-end.
- [ ] Each broken function has a stated symptom and a hidden bug; solution cells provided.
- [ ] At least one exercise where the student writes their own `assert`-based test.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.