Skip to content

Redesign kitAST.oeis: Default/override generators, 8x faster regeneration - #39

Merged
hunterhogan merged 1 commit into
mainfrom
claude/relaxed-einstein-y4he2q
Nov 30, 2026
Merged

hunterhogan merged 1 commit into
mainfrom
claude/relaxed-einstein-y4he2q

Conversation

@hunterhogan

Copy link
Copy Markdown
Owner

Summary

Regenerating byFormula.py, test_byFormula.py, test_relationsTriangle.py, and tests/dataSamples/oeis.py took 2m44s. It now takes about 20s. Apart from module docstrings, the generated code is identical: I compared ASTs against the original generator's output from a worktree at main.

Where the time went

  • 117s, relation tests. makeIndicesRelation substituted n into the whole Equality, so SymPy tried to decide whether expressions of unknown sequence values are equal. Then instantiateSide substituted into each side again. _symbolic.makeInstancesRelation now substitutes and evaluates each side once and checks the stored values on the result. It replaces makeIndicesRelation and expressionStored吗.
  • Autoflake. Its useless-pass scan is quadratic: 163s on the 2 MB relation-test module. The old ignore_pass_statements: True setting avoided it, so the generated modules keep that setting.
  • Formula tests. Selectors were recomputed with makeBoxOf_f for every request. They are now computed once.

Design

  • Modules: makeModules (makeModulesOEIS), _byFormula, _parametersTest, and _tests. They replace oeisModules, oeisIDByFormula, and oeisTests.
  • Each generator (makeByFormula, makeTestsByFormula, makeTestsTriangle, makeSamples) takes identifiers: Default | None and **override: Unpack[DefaultOverride]. A new defaultOEIS in kitAST.theSSOT holds the module names, logical paths, test-function names, and the samples variable. The test modules now import byFormula and the samples through those identifiers instead of string literals.
  • resolvePathFilenameModule (kitAST._beDRY) is the path resolution that toDisk used. makeSamples uses it to read its previous output. The other generators still write byte-identical files.
  • makeLookupSolutions identifies each solution of a sequence by its selector once (形Solution). Type aliases 形ParameterFormula, 形ParameterRelation, and 形Reference replace the repeated tuple types.
  • Generated modules get their docstrings from IngredientsModule.docstring. The Contents section is now omitted for a module without public functions, and an entry omits an empty summary line instead of leaving trailing whitespace.

Testing

  • pytest on test_byFormula.py, test_relationsTriangle.py, test_oeis.py, test_kitAST.py, and test_pyproject.py: 7182 passed, 1 xfailed. 2 errors are test_optionalDependencies for the oeisdata and ortools extras, which are not installed in this environment.
  • The map-folding, meanders, axis, and symmetric generators, after the Ruff step from synthesizeModules.cmd, produce no diff.
  • Ruff: clean. Pyrefly: no new errors; the remaining SymPy-typing errors were already in the old modules.

byFormula.py is committed with only its new docstring. In this environment, both the old and the new generator order a few SymPy terms differently and report valueUnknown 301 instead of 401 for A400632 and A400633. That comes from this environment's data, not from this change.


Generated by Claude Code

Regenerating byFormula, its tests, and their samples took 2m44s; it takes
about 20s now, with identical generated code.

- Relation tests: instantiate each side once. The old path substituted n
  into the whole Equality, so SymPy tried to decide equality of unknown
  sequence values, then substituted into each side again.
  `_symbolic.makeInstancesRelation` replaces `makeIndicesRelation` and
  `expressionStored吗`.
- Autoflake keeps `ignore_pass_statements`: its useless-pass scan is
  quadratic and costs minutes on the 2 MB relation-test module.
- Modules: `makeModules` (makeModulesOEIS), `_byFormula`,
  `_parametersTest`, `_tests`, replacing oeisModules, oeisIDByFormula,
  and oeisTests.
- Each generator takes `identifiers` and `**override`; `defaultOEIS`
  holds the module names, logical paths, test names, and the samples
  variable, so the test modules import byFormula and the samples through
  identifiers instead of literals. `resolvePathFilenameModule` holds the
  path resolution that `toDisk` used.
- Solutions are identified by their selector once (`makeLookupSolutions`,
  `形Solution`) instead of recomputing selectors for every test request.
- Generated modules take their docstrings from IngredientsModule; the
  Contents section is omitted when a module has no public function, and an
  entry omits an empty summary line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GMd3z8jjYb2eqKRTMNwbAH
@hunterhogan
hunterhogan marked this pull request as ready for review November 30, 2026 14:01
@hunterhogan
hunterhogan merged commit e7095c6 into main Nov 30, 2026
13 checks passed
@hunterhogan
hunterhogan deleted the claude/relaxed-einstein-y4he2q branch November 30, 2026 14:04
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