Conversation
… indexing df_wrapcols() in _kwarg_help.py indexed rows with `df.loc[ix,]`. The trailing comma turns the key into a 1-tuple, which older pandas silently treated the same as `df.loc[ix]`, but current pandas treats any tuple key to .loc as multi-axis indexing and zips it against DataFrame._AXIS_ORDERS (length 2) with strict=True, raising `ValueError: zip() argument 2 is longer than argument 1` for a 1-tuple. This broke every call to mpf.kwarg_help(), including the one covered by tests/test_kwarg_help.py. Fix: drop the stray trailing comma so the key is a plain scalar (`df.loc[ix]`), which is what was actually intended and what pandas' row-selection API expects. Verified: tests/test_kwarg_help.py::test_kwarg_help now passes (was failing before the fix); confirmed red before / green after by reverting and reapplying the change. Full test suite: 43 failed / 8 passed before -> 42 failed / 9 passed after, with no new failures introduced (remaining failures are pre-existing, unrelated pandas/ matplotlib compatibility issues, including one already tracked in open PR matplotlib#699). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Bug
mpf.kwarg_help()raisesValueError: zip() argument 2 is longer than argument 1on current pandas (tested with pandas 3.0.6, but the same failure occurs on any pandas 2.x that enforcesstrict=Truezip in_LocIndexer._multi_take). This is a 100% reproduction on the existingtests/test_kwarg_help.py::test_kwarg_helptest.Root cause
df_wrapcols()insrc/mplfinance/_kwarg_help.pyselects each row with:The trailing comma turns
ix,into the 1-tuple(ix,). Older pandas treated a 1-tuple key to.locthe same as the bare scalar. Current pandas routes any tuple key through_getitem_tuple->_multi_take, which does:self.obj._AXIS_ORDERSfor a DataFrame has length 2 (index, columns), buttuphere has length 1, sozip(..., strict=True)raisesValueError. Minimal repro outside mplfinance:Fix
Drop the stray trailing comma so the key is a plain scalar, which is what was actually intended (
df.loc[ix]), and is a strict subset of the existing behavior — no other code path is touched.Verification
tests/test_kwarg_help.py::test_kwarg_help: fails onmaster(ValueError: zip() argument 2 is longer than argument 1), passes after this change.tests/suite: 43 failed / 8 passed before -> 42 failed / 9 passed after, with no new failures introduced. The remaining failures are pre-existing and unrelated (mostly image-comparison baseline drift from newer matplotlib rendering, and an ATR/.locindexing bug in the P&F/renko code path that is already tracked in open PR Add traditional box scaling for P&F charts and fix ATR indexing bug #699).Environment used for verification: fresh clone, Python 3.12 venv,
pip install -e ., pandas 3.0.6 / numpy 2.5.3 / matplotlib 3.11.2 (current latest as of testing).🤖 Generated with Claude Code