Skip to content

Commit

Permalink
Use pyplot.get_cmap instead of cm.get_cmap
Browse files Browse the repository at this point in the history
matplotlib.cm.get_cmap has been removed in matplotlib 3.9.0
  • Loading branch information
isaksamsten committed Jun 24, 2024
1 parent c9de5a9 commit 4d07f94
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 16 deletions.
4 changes: 2 additions & 2 deletions docs/_gen_figures/gen_datasets_repository.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
from light_dark import mk_light_dark
from matplotlib.cm import get_cmap
from wildboar import iseos
from matplotlib.pyplot import get_cmap
from wildboar.utils.variable_len import is_end_of_series
from wildboar.datasets import load_dataset, load_gun_point
from wildboar.datasets.preprocess import minmax_scale, truncate

Expand Down
6 changes: 3 additions & 3 deletions docs/_gen_figures/gen_outlier.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ def plot_inlier_outlier(

ax[1].set_title("Distribution")

ax[1].bar(label, value, color=plt.cm.get_cmap(lut=2).colors)
ax[1].bar(label, value, color=plt.get_cmap(lut=2).colors)

ax[2].set_title("Time series")
plot.plot_time_domain(
x_outlier, y=y_outlier, ax=ax[2], n_samples=10, cmap=plt.cm.get_cmap(lut=2)
x_outlier, y=y_outlier, ax=ax[2], n_samples=10, cmap=plt.get_cmap(lut=2)
)


Expand All @@ -53,7 +53,7 @@ def make_projection(*, x, x_outlier):


def plot_projection(*, original_projection, outlier_projection, y_outlier, ax):
cmap = plt.cm.get_cmap(lut=3)
cmap = plt.get_cmap(lut=3)
ax.scatter(
original_projection[:, 0],
original_projection[:, 1],
Expand Down
3 changes: 0 additions & 3 deletions src/wildboar/ensemble/_ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,10 +839,7 @@ def fit(self, x, y, sample_weight=None):
max_samples=self.max_samples,
max_depth=self.max_depth,
sample_weight=sample_weight,
<<<<<<< HEAD
=======
check_input=False,
>>>>>>> c7ab42773 (Fix bugs introduced with scikit-learn 1.5.)
)
return self

Expand Down
6 changes: 2 additions & 4 deletions src/wildboar/explain/_importance.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
from ..utils.validation import check_array, check_option

try:
from matplotlib.axes import Axes
from matplotlib.cm import ScalarMappable, get_cmap
from matplotlib.pylab import subplots
from matplotlib.cm import ScalarMappable
from matplotlib.pyplot import get_cmap, subplots

from ..utils.plot import MidpointNormalize, plot_frequency_domain, plot_time_domain
except ModuleNotFoundError as e:
Expand All @@ -35,7 +34,6 @@
subplots = matplotlib_missing
MidpointNormalize = matplotlib_missing
plot_time_domain = matplotlib_missing
Axes = matplotlib_missing

Importance = namedtuple("Importance", ["mean", "std", "full"])

Expand Down
10 changes: 6 additions & 4 deletions src/wildboar/utils/plot.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
# Authors: Isak Samsten
# License: BSD 3 clause
"""
Plotting utilities.
"""

import numpy as np
from sklearn.utils import column_or_1d, resample

from ..utils.validation import check_array

try:
import matplotlib.pylab as plt
from matplotlib.cm import get_cmap
from matplotlib.collections import LineCollection
from matplotlib.colors import Normalize
from matplotlib.lines import Line2D
from matplotlib.pyplot import get_cmap, subplots
except ModuleNotFoundError as e:
from ..utils import DependencyMissing

Expand Down Expand Up @@ -102,7 +104,7 @@ def plot_time_domain(
>>> plot_time_domain(X, y, n_sample=10)
"""
if ax is None:
fig, ax = plt.subplots()
fig, ax = subplots()

x = check_array(np.atleast_2d(x), input_name="x", allow_3d=False, order=None)
if y is not None:
Expand Down Expand Up @@ -199,7 +201,7 @@ def plot_frequency_domain(
>>> plot_frequency_domain(X, y, n_sample=10)
"""
if ax is None:
fig, ax = plt.subplots()
fig, ax = subplots()

x = check_array(x, allow_3d=False, order=None)
if y is not None:
Expand Down

0 comments on commit 4d07f94

Please sign in to comment.