Skip to content

Test the book's examples against WMA's results - #8

Merged
rocky merged 1 commit into
masterfrom
book-examples-tests
Oct 30, 2026
Merged

rocky merged 1 commit into
masterfrom
book-examples-tests

Conversation

@tombouctou

Copy link
Copy Markdown
Contributor

The examples of Pemmaraju and Skiena's Computational Discrete Mathematics (Chapters 3 to 5, "New Features" and the tutorial notebook) as tests, checked against what WMA 15 gives.

  • test/test_book_examples.py evaluates each notebook's cells in order, in one session with the package loaded. A cell whose WMA result is deterministic (the same under two random seeds, not timing anything) is checked against it; the others are evaluated, since later cells use what they define, but not checked.
  • book/ holds the cells, the WMA and Mathics3 runs the test data is made from, the harnesses that make those runs, and make_tests.py, which writes test/data/book/. book/README.md says how to refresh it.
  • By default only the cells that ran in at most 1 s are evaluated (COMBINATORICA_BOOK_SECS=5 takes more), and any cell is stopped after 30 s. A cell that uses a symbol which a skipped cell assigns is skipped too.

Checked cells: 201 (Chapter 3), 96 (Chapter 4), 197 (Chapter 5), 47 (New Features), 50 (tutorial).

With COMBINATORICA_BOOK_SECS=5: 807 passed on mathics-core with the open fixes and package PR #7; 21 fail on mathics-core master with this package's master. Those 21 are in book/xfail.json with the fix each one needs (Transpose of deep lists mathics-core#2090, the Compile-style argument patterns #7, the recursion limit mathics-core#2080, and part assignment mathics-core#2083–#2085), as non-strict xfails, so they can be dropped from the list as the fixes are merged.

🤖 Generated with Claude Code

The examples of Pemmaraju and Skiena's "Computational Discrete
Mathematics" (Chapters 3 to 5, "New Features" and the tutorial
notebook) become test/test_book_examples.py: each notebook's cells run
in order in one session with the package loaded, and the cells whose
WMA 15 result is deterministic are checked against it.

book/ holds the cells, the WMA and Mathics3 runs they are made from,
the harnesses that make those runs, and make_tests.py, which writes
test/data/book/. By default the tests take the cells that ran in at
most 1 s (COMBINATORICA_BOOK_SECS raises that), and stop any cell after
30 s. book/xfail.json lists the cells that need fixes not yet merged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rocky

rocky commented Oct 30, 2026

Copy link
Copy Markdown
Member

WOW! One thing I have learned over these many years is that when someone has a vision and is better than you, the best thing you can do is get out of the guy's way.

@rocky
rocky merged commit 9282297 into master Oct 30, 2026
1 check passed
@tombouctou
tombouctou deleted the book-examples-tests branch October 31, 2026 11:43
@tombouctou

Copy link
Copy Markdown
Contributor Author

@rocky Glad to hear, thank you!

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.

2 participants