A marimo notebook that teaches environmentally extended input-output analysis on a synthetic economy of 9 sectors: the Leontief quantity model, the carbon footprint of final demand and a scenario you change with a slider. It ends with self-checks modelled on the checks a scenario explorer runs against RaMa-Scene. It needs only numpy, so it also runs in the browser through Pyodide.
The notation follows Miller and Blair (2009), Input-Output Analysis:
Foundations and Extensions, second edition:
uv run marimo edit io_leontief.py # edit and run
uv run marimo run io_leontief.py # app viewExport to a static page (--mode edit lets readers change the code). The page
loads Pyodide and packages from cdn.jsdelivr.net, so readers need internet
access. dist/ is not committed.
uv run marimo export html-wasm io_leontief.py -o dist --mode run
python3 -m http.server --bind 127.0.0.1 8000 --directory distuv run pytest # pure functions, harness checks, and a headless run of every cell
uv run ruff check . && uv run ruff format --check .
uv run marimo check io_leontief.py
# browser smoke test against a served dist/ (install Chromium once first):
uv run --with playwright playwright install chromium
uv run --with playwright python scripts/check_wasm.py http://127.0.0.1:8000/ dist/shot.pngThe page is live at https://simonvanlierde.com/io-notebook/. Every push
to main that passes the checks exports the page, smoke-tests it in Chromium
and deploys it to GitHub Pages.
Each pull request gets a preview at a pr-<number> address on Cloudflare
Workers, linked from the PR as its preview deployment (wrangler.jsonc). The
job needs CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID in the preview
environment's secrets, and skips without them. Drafts get no preview. When a PR
closes or turns draft, preview-retire.yml points its address at a short
"preview closed" page, since wrangler cannot delete an alias.
The notebook uses synthetic data only. I took its recipe, a seeded
numpy.random.default_rng and a dense, non-symmetric matrix, from a RaMa-Scene
regression harness, which is public on my fork of RaMa-Scene.
The same harness is an open pull request against the upstream repository
(#72).
The code is released under the MIT licence.