Add cap-to-weight order contract#95
Merged
Merged
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.
Summary
This PR makes the cap-to-weight ordering contract explicit without changing the existing Python default.
convert_cap_to_weighthistorically follows the MATLAB legacycap2weightconvention:MATLAB's newer
cdacwgtinterface uses the opposite convention:This PR adds explicit order controls:
input_order=lsb_to_msbkeeps the existing Python /cap2weightbehavior.input_order=msb_to_lsbaccepts MATLABcdacwgt-ordered inputs.output_order=Nonedefaults to the same order asinput_order.output_order=lsb_to_msb | msb_to_lsbcan be selected independently.Why
The recursive capacitance calculation is already the same algorithm. The mismatch is an API contract issue: callers can easily pass a MATLAB
cdacwgtarray into Python and silently get weights in the wrong bit order. Making the order explicit removes that ambiguity while preserving backward compatibility.Validation
Current MATLAB
cdacwgtreference for the segmented bridge case:Current MATLAB returns:
Python with
input_order=msb_to_lsb, output_order=msb_to_lsbnow returns the same values.Default behavior remains unchanged:
Tests
I intentionally did not update bundled skill docs in this PR to avoid overlapping with the currently open documentation PRs. A follow-up docs-only PR can add the new order options after those land.