Skip to content

Close the standard's remaining gaps: tables, imports, alt text, release pin - #4

Merged
yamierick merged 1 commit into
mainfrom
standards/gaps
Oct 27, 2026
Merged

yamierick merged 1 commit into
mainfrom
standards/gaps

Conversation

@yamierick

Copy link
Copy Markdown
Contributor

Closes the four code-standard gaps that were still open. Each one is now enforced by a test or a checker rule that fails, not by a line in the README.

  1. Data tables can be found from anywhere. New orteach.paths.table(). It looks in this order:

    • an explicit argument;
    • $ORTEACH_DATA;
    • data/raw beside the code;
    • data/raw under the working directory;
    • the release's raw URL, fetched once and cached.

    If you name a location (the first two) and the file isn't there, it raises an error instead of quietly using a different copy. Previously all 14 modules walked up from __file__, which breaks after pip install, and some did it in default arguments, which are evaluated at import time.

  2. Every import is declared. A new test scans the imports in src/, notebooks/ and tests/ and checks them against pyproject.toml.

  3. Every figure has a text alternative. Each figure cell now prints a Figure: line describing what the image shows, and the checker rejects any figure cell without one. Six figures were missing it (three in notebook 08, three in notebook 14).

  4. On Colab, notebooks clone the release, not main. The setup cell's REF must match orteach.paths.TAG, and the checker enforces that.

Each guard was checked by breaking it: I injected the defect it targets, confirmed the check failed, removed the defect, and confirmed it passed. The commit message has the details.

Re-execution: all 17 notebooks were re-run. The outputs match main apart from the new Figure: lines, one branch-and-bound node count from a time-limited solve, and one -0.0 that now prints as 0.0. No number quoted in the prose changed.

Next: once this is merged, a games notebook (the flu and coin games) follows, then the v1.0.0 tag on the merge commit.

🤖 Generated with Claude Code

…elease pin

Four things the code standard asks for that this library did not do, each
now enforced by something that fails rather than by a README line.

1. Tables reachable from anywhere (Part 4). All 14 modules found data/raw
   by walking up from __file__: right in a clone, wrong after
   `pip install git+...`, which ships no data/. Several did it inside a
   default argument, frozen at import time. orteach.paths.table() is now
   the one resolver, local first: an explicit data_dir=, then
   $ORTEACH_DATA (both refused if the file is missing, never skipped),
   then data/raw beside the code, then under the cwd, then the raw URL at
   the release TAG, fetched once and cached. Loaders take path=None and
   resolve at call time; writers write into the clone's own data/raw.
   tests/test_paths.py pins each rule by name. Watched to fail: a named
   location falling through failed two tests; the URL ahead of the local
   copy failed one.

2. Every import declared (Part 6). tests/test_dependencies.py parses (never
   imports) every import in src/, notebooks/ and tests/ and compares with
   pyproject.toml, which it reads rather than restates. Unknown
   distributions fail instead of being guessed at. tomli is declared for
   3.10 instead of skipped. Watched to fail on an injected `import yaml`
   in a module and, separately, in a notebook.

3. A text alternative for every figure (Part 3, accessibility; WCAG 2.1 AA
   from 2027-04-26). The six committed figures (08 x3, 14 x3) had none. Each
   cell now prints a "Figure:" line saying what the image shows, computed
   from the same data; the dart scatter separates inside from outside by
   marker as well as colour. check_notebooks.py refuses any image cell
   without one. Watched to fail: it flagged exactly those six cells before
   the fix.

4. Notebooks clone the release, not main (Part 4, Part 5 "tag what you
   hand out"). Every setup cell gains REF and clones --branch REF. REF must
   equal orteach.paths.TAG, the tag the package fetches tables from;
   check_notebooks.py reads TAG from source and refuses a mismatch.
   Watched to fail on the 11 seeded notebooks before they were
   regenerated. README "Cutting a release" has the steps. TAG is v1.0.0,
   which this PR's merge commit is meant to become.

All 17 notebooks re-executed. Their outputs match HEAD except the new
Figure lines, a branch-and-bound node count in 06's time-limited run (the
same bound; node counts under a time limit vary), and -0.0 printed as 0.0
in pooling. No prose number moved; the checker confirms.

Gate: 191 passed (base); 21 in the energy venv with
ORTEACH_REQUIRE_PYPSA=1; 17 notebooks and 11 seeds clean; ruff clean.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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