Skip to content

Commit

Permalink
CLN: do not import Axes/Artist/Figure from matplotlib.pyplot (#55192)
Browse files Browse the repository at this point in the history
CLN: do not import Axes/Artist from matplotlib.pyplot
  • Loading branch information
twoertwein authored Sep 19, 2023
1 parent 6a65cfd commit 20949e2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pandas/_testing/asserters.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,22 +416,23 @@ def assert_attr_equal(attr: str, left, right, obj: str = "Attributes") -> None:


def assert_is_valid_plot_return_object(objs) -> None:
import matplotlib.pyplot as plt
from matplotlib.artist import Artist
from matplotlib.axes import Axes

if isinstance(objs, (Series, np.ndarray)):
for el in objs.ravel():
msg = (
"one of 'objs' is not a matplotlib Axes instance, "
f"type encountered {repr(type(el).__name__)}"
)
assert isinstance(el, (plt.Axes, dict)), msg
assert isinstance(el, (Axes, dict)), msg
else:
msg = (
"objs is neither an ndarray of Artist instances nor a single "
"ArtistArtist instance, tuple, or dict, 'objs' is a "
f"{repr(type(objs).__name__)}"
)
assert isinstance(objs, (plt.Artist, tuple, dict)), msg
assert isinstance(objs, (Artist, tuple, dict)), msg


def assert_is_sorted(seq) -> None:
Expand Down

0 comments on commit 20949e2

Please sign in to comment.