fix: address pandas chained-assignment FutureWarning ahead of pandas 3.0#39
Open
tabedzki wants to merge 3 commits into
Open
fix: address pandas chained-assignment FutureWarning ahead of pandas 3.0#39tabedzki wants to merge 3 commits into
tabedzki wants to merge 3 commits into
Conversation
…urvey_file Replace per-column loop assignment on a sliced-then-copied DataFrame with a single assign().astype() so column dtypes are set in one step. This silences the pandas 2.3 ChainedAssignmentError FutureWarning (a refcount-sensitive false positive that fires in the real call path) ahead of the pandas 3.0 copy-on-write default, while preserving the ValueError-on-bad-data contract. Assisted-by: ClaudeCode:claude-opus-4.8
…_wiring_df The two consecutive df[column] = ... assignments per loop iteration triggered the pandas 2.3 ChainedAssignmentError FutureWarning in the real call path (the elevated DataFrame refcount that the warning keys on is only present when called through the app, not in isolation). Build each tuple column as an object-dtype Series and apply them in a single assign(), which sets the values in one step ahead of the pandas 3.0 copy-on-write default. Assisted-by: ClaudeCode:claude-opus-4.8
Run uv sync --upgrade to refresh the lockfile (pandas 2.3.1 -> 3.0.3 on Python >=3.11, panel 1.7.5 -> 1.9.3, numpy -> 2.5.1, and ~48 others). Raise the pandas constraint from >=2.0.0 to >=2.3 so the resolved version is one where the chained-assignment behaviour matches the copy-on-write fixes in this branch. Keep requires-python >=3.10: pandas 3.0 dropped 3.10, so the lock resolves pandas 2.3.x for py<3.11 and 3.0.x for py>=3.11 via markers. Full test suite passes on pandas 3.0.3, including with FutureWarning promoted to error. Assisted-by: ClaudeCode:claude-opus-4.8
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.
🤖 AI text below 🤖
What
Silences the pandas 2.3
ChainedAssignmentErrorFutureWarningin two DataFrame-transform spots so the code is ready for the pandas 3.0 copy-on-write default.pixelmap/utils/survey.py(parse_survey_file): replace the per-column loop assignment on a sliced-then-copied DataFrame with a singleassign().astype().pixelmap/backend.py(format_wiring_df): replace the two consecutivedf[column] = ...assignments per loop iteration with object-dtype Series applied in a singleassign().Why
Under pandas 2.3 these assignments emit:
The warning is a refcount-sensitive false positive — the assignments aren't truly chained — but it fires in the real call path (not in isolation), and the underlying single-step-assignment guidance is the correct forward-compatible form. Both rewrites set column values in one step, which is warning-free now and correct under pandas 3.0 copy-on-write.
Behaviour is unchanged:
parse_survey_filestill raisesValueErroron unparseable data, andformat_wiring_dfstill returns the same(shank_id, electrode_id)tuple cells.Verification
-W error::FutureWarning.FutureWarningpromoted to error:120 passed.inplace=, chaineddf[..][..]=,.applymap,.iteritems,.appendon DataFrames,.ix, etc.) — these two were the only affected spots.