Skip to content

Commit

Permalink
fix matplotlib deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
adrinjalali committed Jun 4, 2024
1 parent effd5ba commit 361f566
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions skops/card/_model_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from skops.card._templates import CONTENT_PLACEHOLDER, SKOPS_TEMPLATE, Templates
from skops.io import load
from skops.utils.importutils import import_or_raise
from skops.utils._fixes import boxplot

if sys.version_info >= (3, 11):
from typing import Self
Expand Down Expand Up @@ -1225,9 +1226,9 @@ def add_permutation_importances(
)
sorted_importances_idx = permutation_importances.importances_mean.argsort()
_, ax = plt.subplots()
ax.boxplot(
boxplot(ax,
x=permutation_importances.importances[sorted_importances_idx].T,
labels=columns[sorted_importances_idx],
tick_labels=columns[sorted_importances_idx],
vert=False,
)
ax.set_title(plot_name)
Expand Down
6 changes: 6 additions & 0 deletions skops/utils/_fixes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
def boxplot(ax,*, tick_labels, **kwargs):
"""A function to handle labels->tick_labels deprecation."""
try:
return ax.boxplot(tick_labels=tick_labels, **kwargs)
except TypeError:
return ax.boxplot(labels=tick_labels, **kwargs)

0 comments on commit 361f566

Please sign in to comment.