docs: split examples into topic pages backed by runnable scripts - #1350
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7acca754de
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| alive = np.ones(len(state), dtype=bool) | ||
| for _ in range(HORIZON): | ||
| raw = np.asarray(model.predict(observe(state), index=index), dtype=float) | ||
| force = FORCE_CAP * np.clip(np.nan_to_num(raw, nan=0.0), -1.0, 1.0) |
There was a problem hiding this comment.
Reject non-finite policy outputs during held-out validation
When the policy returns NaN or infinity for a still-alive held-out trajectory, this conversion silently turns NaN into zero force and infinities into saturated force, so check() can report that all held-out starts succeeded even though the policy was undefined. The Julia training objective explicitly rejects the same outputs with Inf; mark the affected held-out starts invalid rather than sanitizing their actions.
Useful? React with 👍 / 👎.
| @pytest.mark.parametrize("name", [n for n, s in EXAMPLES.items() if s <= FAST_SECONDS]) | ||
| def test_example(name): | ||
| run(name) |
There was a problem hiding this comment.
Wire the new example tests into CI
These tests are never discovered by the current CI: the test steps in .github/workflows/CI.yml:82-89 and .github/workflows/CI_large_nightly.yml:48-49 invoke python -m pysr test, whose dispatcher only loads unittest classes under pysr/test, while the documentation workflow only generates markdown. Consequently neither these fast runnable examples nor the later documentation invariants execute on pull requests, and regressions can merge despite the added coverage.
Useful? React with 👍 / 👎.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
The single examples page had grown to sixteen numbered sections, and the code in it was not runnable as written. Each section is now a page grouped by what the reader wants, and every code block is a slice of a script under `examples/` that runs on its own. `examples/test_examples.py` runs each script and checks the result the page claims, and holds the structural invariants: the sidebar, the index, and the page bodies agree on one reading order, no example is missing from the index, and no string literal is split across lines in a way the docs blocks hide. Co-authored-by: Miles Cranmer <miles.cranmer@gmail.com>
Co-authored-by: Miles Cranmer <miles.cranmer@gmail.com>
7acca75 to
6cf8f76
Compare
Co-authored-by: Miles Cranmer <miles.cranmer@gmail.com>
Co-authored-by: Miles Cranmer <miles.cranmer@gmail.com>
Co-authored-by: Miles Cranmer <miles.cranmer@gmail.com>
Split the examples index into eight topic pages under
docs/src/examples/, with runnable scripts underexamples/and matching sidebar navigation.The pages cover standard fitting, expression specifications, custom objectives, physics and units, search configuration, instrumentation, custom value types, and symbolic controllers. They include the recovered equations while keeping run-by-run analysis out of the walkthroughs. The Hopper script replays the saved controller; the agent-loop example uses stored proposals.
Twelve demonstration videos are hosted separately in PySR_Docs #11. Embeds use immutable URLs pinned to asset commit
38b98e49200ee5e1629a62fb7e0b811d64286154; no MP4 files are added to this repository.Verification: