Repository navigation
fix(notebooks): illustrate 05 and 12 - #64
Merged
Merged
Conversation
…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.
2 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
RuntimeWarning: invalid value encountered in subtractin their stored outputs, and a warning names the file that raised it. Root cause: every optimizer wrapper scores an unbuildable candidate as+infon purpose, so scipy's finite differences (dual_annealing, DE's polish, gradient methods inminimize_linkage) and pymoo's crowding distance (multi_objective_optimization,co_optimize) computeinf - inf. The wrappers now run the third-party optimizer undernumpy.errstate(invalid="ignore").eliminate_theta()rewrotecosassin(theta + pi/2)before substitutingcos(theta), so nothing was substituted and it returned an expression still intheta(the notebook printed a "degree 0" curve). Rewritten: direct substitution, each square root becomes an unknownrwithr**2 = R, floats are read as exact rationals,cos(2θ)and the like are expanded. The four-bar rocker tip gives(x-4)² + y² = 9in ~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.main.Test plan
uv run pytest— 2671 passed