Enforce 1-based public trap_index across trap analysis and removal APIs#388
Open
charlesmartin14 wants to merge 2 commits intomasterfrom
Open
Enforce 1-based public trap_index across trap analysis and removal APIs#388charlesmartin14 wants to merge 2 commits intomasterfrom
trap_index across trap analysis and removal APIs#388charlesmartin14 wants to merge 2 commits intomasterfrom
Conversation
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.
Motivation
trap_indexto be 1-based across analysis/artifact outputs and the removal API to avoid off-by-one confusion between internal SVD mode indices and user-visible indices.trap_indexvalues early inremove_trapsto prevent passing zero-based indices into the ablation workflow.Description
analyze_trapsto enumerate trap mode indices starting at1, record artifacttrap_indexvalues as 1-based, and adjust plotting and artifact assembly to expect 1-basedtrap_indexvalues._top_trap_component_rowto treat the incomingtrap_indexas already-public (1-based) and stop adding+1there.remove_trapsand_trap_indices_from_traps_dfwith validation thattrap_indexvalues are>= 1, improve handling of per-layer traps selection and propagateselected_trap_indicesthrough cached and non-cached removal paths, and make error messages consistent.apply_remove_trapsto validate non-empty, 1-basedtrap_indicesand update the raised error message when invalid indices are detected.test_top_trap_component_row, addtest_analyze_traps_public_trap_indices_are_1_basedandtest_remove_traps_rejects_zero_based_public_trap_index, and simplify a test helper intest_trap_compute_efficiency.py.Testing
tests/test_analyze_traps.py,tests/test_trap_ablation_workflow.py,tests/test_trap_component_summary.py, andtests/test_trap_compute_efficiency.pywhich exercise artifact generation, remove workflow, component extraction, and SVD-call behavior respectively, and they all passed.ValueErrorwhen zero-based publictrap_indexvalues are provided toremove_trapsusing the added test case which succeeded.trap_indexvalues via the added integration-style test which succeeded.Codex Task