Skip to content

fix(notebooks): illustrate 05 and 12 - #64

Merged
HugoFara merged 1 commit into
mainfrom
fix/notebook-outputs
Sep 18, 2026
Merged

HugoFara merged 1 commit into
mainfrom
fix/notebook-outputs

Conversation

@HugoFara

@HugoFara HugoFara commented Sep 18, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Notebooks 02, 10 and 11 carried RuntimeWarning: invalid value encountered in subtract in their stored outputs, and a warning names the file that raised it. Root cause: every optimizer wrapper scores an unbuildable candidate as +inf on purpose, so scipy's finite differences (dual_annealing, DE's polish, gradient methods in minimize_linkage) and pymoo's crowding distance (multi_objective_optimization, co_optimize) compute inf - inf. The wrappers now run the third-party optimizer under numpy.errstate(invalid="ignore").
  • Notebooks 05 and 12 had no stored outputs at all; they are executed and their figures are in.
  • Executing 05 exposed a bug: eliminate_theta() rewrote cos as sin(theta + pi/2) before substituting cos(theta), so nothing was substituted and it returned an expression still in theta (the notebook printed a "degree 0" curve). Rewritten: direct substitution, each square root becomes an unknown r with r**2 = R, floats are read as exact rationals, cos(2θ) and the like are expanded. The four-bar rocker tip gives (x-4)² + y² = 9 in ~0.4 s; the soft "skip if it fails" test is replaced by exact ones. Symbolic lengths and a joint built on a second dyad (nested roots) are still slow — documented.
  • Notebooks 02, 10, 11 re-executed against current main.

Test plan

  • uv run pytest — 2671 passed
  • ruff, mypy clean
  • All five re-executed notebooks: no stderr output, figures present
  • CI "Executable docs"

…te 05 and 12

Three tutorial notebooks carried a RuntimeWarning in their outputs, and a
warning names the file that raised it — the absolute path of the venv on
the machine that executed them. The warning itself is expected: every
optimizer wrapper scores an unbuildable candidate as +inf on purpose, and
scipy's finite differences and pymoo's crowding distance then compute
inf - inf. The wrappers now run the third-party optimizer under
numpy.errstate(invalid="ignore"), and a new test refuses any notebook
whose outputs name a home directory.

Notebooks 05 and 12 had never been executed: their figures are now stored.
Executing 05 showed that eliminate_theta() returned an expression still in
theta (it rewrote cos as sin before substituting cos). It now substitutes
directly, turns each square root into an unknown with a polynomial
constraint, and reads floats as exact rationals; the four-bar rocker tip
gives its circle in under a second. The notebook explains why that curve
has degree 2 and not 6.

Notebooks 02, 10 and 11 are re-executed against the current code.
@HugoFara HugoFara changed the title fix(notebooks): keep private paths out of committed outputs, illustrate 05 and 12 fix(notebooks): illustrate 05 and 12 Sep 18, 2026
@HugoFara
HugoFara merged commit 3344f15 into main Sep 18, 2026
10 checks passed
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