Skip to content

Avoid Matplotlib 3.11 vert deprecation in permutation importance plots - #530

Draft
adrinjalali with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-matplotlib-deprecation-warning
Draft

Avoid Matplotlib 3.11 vert deprecation in permutation importance plots#530
adrinjalali with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-matplotlib-deprecation-warning

Conversation

Copilot AI commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Permutation-importance model card tests were tripping MatplotlibDeprecationWarning (vert deprecated in Matplotlib 3.11), which breaks warning-strict downstream builds. This PR updates our matplotlib compatibility shim to stop forwarding deprecated args on newer matplotlib while preserving behavior on older versions.

  • Compatibility layer update (skops.utils._fixes.boxplot)

    • Normalize legacy vert input into orientation when provided.
    • Strip vert from kwargs before calling ax.boxplot on matplotlib versions that support orientation.
    • Keep old-version fallback behavior by still emitting vert only when required.
  • Focused regression coverage

    • Add unit tests in skops/utils/tests/test_fixes.py for both version paths:
      • New matplotlib: assert vert is not passed through.
      • Old matplotlib: assert vert is still passed as expected.
  • Behavioral effect

    • The permutation-importance plotting path continues to use the same API from Card.add_permutation_importances, but no longer triggers the vert deprecation warning on modern matplotlib.
# before calling matplotlib:
vert = kwargs.pop("vert", None)
if vert is not None and orientation == "vertical":
    orientation = "vertical" if vert else "horizontal"

if parse(mpl_version) >= parse("3.10"):
    kwargs["orientation"] = orientation
else:
    kwargs["vert"] = orientation == "vertical"

Copilot AI changed the title [WIP] Fix matplotlib deprecation warning in tests Avoid Matplotlib 3.11 vert deprecation in permutation importance plots Aug 3, 2026
Copilot AI requested a review from adrinjalali August 3, 2026 12:16
@adrinjalali

Copy link
Copy Markdown
Member

@copilot this seems to be only triggered in tests, so we can simply modify tests and make sure they don't raise warnings.

Copilot AI commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

@copilot this seems to be only triggered in tests, so we can simply modify tests and make sure they don't raise warnings.

Done in b9672fe. I reverted the runtime compatibility change and updated only the permutation-importance test class to filter the Matplotlib 3.11 vert deprecation warning.

@adrinjalali

Copy link
Copy Markdown
Member

@copilot the filter is the wrong solution, since it will become an actual error soon. The fix needs to completely avoid the warning, not ignore it.

Copilot AI commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

@copilot the filter is the wrong solution, since it will become an actual error soon. The fix needs to completely avoid the warning, not ignore it.

Addressed in de4e766. I removed the warning filter and restored the runtime fix in skops.utils._fixes.boxplot so vert is normalized and not forwarded on newer Matplotlib, with focused compatibility tests for new/old Matplotlib behavior.

@adrinjalali

Copy link
Copy Markdown
Member

@copilot This is the diff I see now.

image

Copilot AI commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

@copilot This is the diff I see now.

image

...

At PR head (de4e766), those filterwarnings lines are removed. I re-checked the branch against origin/main, and the current diff is only in skops/utils/_fixes.py and skops/utils/tests/test_fixes.py. Please refresh the PR view and make sure it isn’t showing the intermediate b9672fe diff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

matplotlib._api.deprecation.MatplotlibDeprecationWarning: vert: bool was deprecated in Matplotlib 3.11 and will be removed in 3.13.

2 participants