Repository navigation
fix: freeze constraints with a MultiIndex dimension - #1022
Open
MaykThewessen wants to merge 2 commits into
Open
MaykThewessen wants to merge 2 commits into
MaykThewessen wants to merge 2 commits into
Conversation
Grid.from_dataset named each index after its dimension with Index.rename, which on a MultiIndex renames the levels and raises "Must pass list-like as `names`". Set the name of a MultiIndex instead and keep its level names. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merging this PR will not alter performance
Comparing Footnotes
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Note
AI-assisted. Claude wrote the fix and test, and ran the checks listed below. I reviewed the diff.
Changes proposed in this Pull Request
Freezing a constraint over a
MultiIndexdimension raisedTypeError: Must pass list-like as names.Grid.from_datasetnamed each index after its dimension withIndex.rename, and on aMultiIndexthat renames the levels. It now sets the name of aMultiIndexand keeps its level names, through a small_namedhelper.CSRLinearExpression.from_grouperused the samerenamecall, so it uses the helper too; that path is only reachable under v1 today, which rejectsMultiIndexdims, so it is a consistency change. Found while working on #1021.Checklist
AGENTS.md).doc.doc/release_notes.rstof the upcoming release is included.What was checked (AI-generated)
test_model_to_netcdf_with_multiindex_frozen_constraintintest/test_io.py(legacy only, like the existingMultiIndexfixture). It fails on master with theTypeErrorabove and passes with the fix.MultiIndexconstraint solves with HiGHS and gives the same duals as the dense constraint, and the model round-trips through netCDF and writes an LP file.oetcextras, HiGHS without SOS).🤖 Generated with Claude Code