perf(optimization): single dict lookup in _add_phase_tracking_costs - #312
Open
dieterolson wants to merge 1 commit into
Open
perf(optimization): single dict lookup in _add_phase_tracking_costs#312dieterolson wants to merge 1 commit into
dieterolson wants to merge 1 commit into
Conversation
Replace the `if jname in joint_name_to_idx` / `joint_name_to_idx[jname]` double hash lookup with one `.get()` call. Values come from `enumerate`, so an index is always an int and `is not None` is a safe presence test. Also records the two matching Bolt learnings in .jules/bolt.md, appended to the existing file. Replaces the rejected consolidated PR #311 and supersedes #309. #307's substance already landed via #308 and #310 is already on main. The pre-commit prettier hook was skipped for this commit: .jules/bolt.md has never been prettier-formatted, so the hook rewrites all 156 pre-existing lines. That reformat is unrelated to this change and is left for a separate PR. Prettier is not a CI gate; quality-gate runs ruff, mypy, bandit and pip-audit, all of which pass locally. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
dieterolson
enabled auto-merge (squash)
August 14, 2026 07:39
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.
Clean minimal replacement for the rejected consolidated PR #311 (review).
What this actually changes
1.
_add_phase_tracking_costs— one dict lookup instead of two (src/drake_models/optimization/drake_trajectory_solver.py)joint_name_to_idxis built as{name: idx for idx, name in enumerate(joint_names)}, so its values are alwaysintand neverNone.is not Noneis therefore an exact presence test — no behaviour change, including for index0.2. Two new
.jules/bolt.mdentries, appended to the existing file (np.searchsortedon small trajectory arrays; dictionary lookups in hot loops).That is the whole diff: 2 files, +12/−4.
Why #311 was replaced rather than fixed
Of the three PRs #311 claimed to close, only one still had new content:
93400b5— which is literally the merge-base of #311's branch, so #311 carried nothing from it.b904fa9).objectives/__init__.pyalready hasclean_arr = np.where(np.isnan(arr), 0.0, arr). #311's only addition was a duplicate of that comment — dropped.#311 also carried damage that this PR deliberately does not reproduce:
.jules/bolt.mdandobjectives/__init__.pywholesale to CRLF (164/0 and 190/0 CRLF/LF) in an otherwise all-LF repo. Both files here are LF-only, verified byte-level after commit.actions/checkoutv7 → v4 downgrades across six workflows, plus an unexplainedcoverage==7.15.4pin inci-standard.yml. No workflow file is touched here.quality-gate, which runsruff format --check. This branch is formatted withruff format.Verification (local, this branch)
One disclosure
The pre-commit prettier hook was skipped for this commit (
SKIP=prettier, not--no-verify— every other hook ran and passed)..jules/bolt.mdhas never been prettier-formatted: prettier rewrites all 156 pre-existing lines of it, and it does so on unmodifiedmaintoo (26953 → 27004 bytes), so this is pre-existing and not introduced here. Applying it would have buried a 12-line change in a 219-line reformat, which is the exact pattern that got #311 rejected. Prettier is not a CI gate —quality-gateruns ruff, mypy, bandit and pip-audit. Normalizing.jules/bolt.mdis left for a separate PR.Closes #309.
🤖 Generated with Claude Code