kangwonlee / kangwonlee/nmisp

Pedagogy: extract comprehensions into standalone notebook under 06_python_advanced/

Open
#394 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

List / dict / set comprehensions are introduced in `00_introduction/30_python_review_2.ipynb` but mixed with closures, `pathlib`, `map` / `filter`, and other functional-programming topics in the same file. Comprehensions are heavily used throughout the rest of NMISP (`[f(x) for x in xs]` patterns appear in every numerical-methods chapter) and deserve a focused, exercise-rich notebook.

## Scope

Create `06_python_advanced/30_comprehensions.ipynb`:

- List comprehension basics: `[f(x) for x in xs]`
- With filter: `[f(x) for x in xs if cond(x)]`
- Nested comprehensions: building 2D structures, flattening
- Dict and set comprehensions
- Generator expressions (brief)
- 4–5 exercises tied to numerical contexts:
- Build a coefficient row vector
- Filter a convergence-history list to only iterations exceeding a tolerance
- Construct a 2D grid of function values
- Build a dict mapping iteration index → residual

Trim the corresponding section from `30_python_review_2.ipynb` once the new notebook is in place (or reduce to a one-line pointer).

## Why

- Comprehensions are a high-leverage Python idiom for numerical code; deserve their own treatment.
- Splitting them out lets `30_python_review_2.ipynb` focus on closures / functional patterns without crowding.

## Acceptance

- [ ] Notebook executes end-to-end.
- [ ] At least 4 exercises with numerical-flavor problems and solution cells.
- [ ] `30_python_review_2.ipynb` no longer duplicates the same teaching.

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.