Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pandas/tests/plotting/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def _check_data(xp, rs):
rs_lines = rs.get_lines()

assert len(xp_lines) == len(rs_lines)
for xpl, rsl in zip(xp_lines, rs_lines):
for xpl, rsl in zip(xp_lines, rs_lines, strict=True):
xpdata = xpl.get_xydata()
rsdata = rsl.get_xydata()
tm.assert_almost_equal(xpdata, rsdata)
Expand Down Expand Up @@ -162,7 +162,7 @@ def _check_colors(collections, linecolors=None, facecolors=None, mapping=None):
linecolors = linecolors[: len(collections)]

assert len(collections) == len(linecolors)
for patch, color in zip(collections, linecolors):
for patch, color in zip(collections, linecolors, strict=True):
if isinstance(patch, Line2D):
result = patch.get_color()
# Line2D may contains string color expression
Expand All @@ -181,7 +181,7 @@ def _check_colors(collections, linecolors=None, facecolors=None, mapping=None):
facecolors = facecolors[: len(collections)]

assert len(collections) == len(facecolors)
for patch, color in zip(collections, facecolors):
for patch, color in zip(collections, facecolors, strict=True):
if isinstance(patch, Collection):
# returned as list of np.array
result = patch.get_facecolor()[0]
Expand Down Expand Up @@ -211,7 +211,7 @@ def _check_text_labels(texts, expected):
else:
labels = [t.get_text() for t in texts]
assert len(labels) == len(expected)
for label, e in zip(labels, expected):
for label, e in zip(labels, expected, strict=True):
assert label == e


Expand Down
18 changes: 9 additions & 9 deletions pandas/tests/plotting/frame/test_frame_color.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def test_line_colors(self):
ax2 = df.plot(color=custom_colors)
lines2 = ax2.get_lines()

for l1, l2 in zip(ax.get_lines(), lines2):
for l1, l2 in zip(ax.get_lines(), lines2, strict=True):
assert l1.get_color() == l2.get_color()

@pytest.mark.parametrize("colormap", ["jet", cm.jet])
Expand Down Expand Up @@ -380,7 +380,7 @@ def test_line_colors_and_styles_subplots_custom_colors(self, color):
# GH 9894
df = DataFrame(np.random.default_rng(2).standard_normal((5, 5)))
axes = df.plot(color=color, subplots=True)
for ax, c in zip(axes, list(color)):
for ax, c in zip(axes, list(color), strict=True):
_check_colors(ax.get_lines(), linecolors=[c])

def test_line_colors_and_styles_subplots_colormap_hex(self):
Expand All @@ -389,7 +389,7 @@ def test_line_colors_and_styles_subplots_colormap_hex(self):
# GH 10299
custom_colors = ["#FF0000", "#0000FF", "#FFFF00", "#000000", "#FFFFFF"]
axes = df.plot(color=custom_colors, subplots=True)
for ax, c in zip(axes, list(custom_colors)):
for ax, c in zip(axes, list(custom_colors), strict=True):
_check_colors(ax.get_lines(), linecolors=[c])

@pytest.mark.parametrize("cmap", ["jet", cm.jet])
Expand All @@ -398,7 +398,7 @@ def test_line_colors_and_styles_subplots_colormap_subplot(self, cmap):
df = DataFrame(np.random.default_rng(2).standard_normal((5, 5)))
rgba_colors = [cm.jet(n) for n in np.linspace(0, 1, len(df))]
axes = df.plot(colormap=cmap, subplots=True)
for ax, c in zip(axes, rgba_colors):
for ax, c in zip(axes, rgba_colors, strict=True):
_check_colors(ax.get_lines(), linecolors=[c])

def test_line_colors_and_styles_subplots_single_col(self):
Expand All @@ -423,7 +423,7 @@ def test_line_colors_and_styles_subplots_list_styles(self):
# list of styles
styles = list("rgcby")
axes = df.plot(style=styles, subplots=True)
for ax, c in zip(axes, styles):
for ax, c in zip(axes, styles, strict=True):
_check_colors(ax.get_lines(), linecolors=[c])

def test_area_colors(self):
Expand Down Expand Up @@ -551,7 +551,7 @@ def test_kde_colors_and_styles_subplots_custom_color(self):
df = DataFrame(np.random.default_rng(2).standard_normal((5, 5)))
custom_colors = "rgcby"
axes = df.plot(kind="kde", color=custom_colors, subplots=True)
for ax, c in zip(axes, list(custom_colors)):
for ax, c in zip(axes, list(custom_colors), strict=True):
_check_colors(ax.get_lines(), linecolors=[c])

@pytest.mark.parametrize("colormap", ["jet", cm.jet])
Expand All @@ -560,7 +560,7 @@ def test_kde_colors_and_styles_subplots_cmap(self, colormap):
df = DataFrame(np.random.default_rng(2).standard_normal((5, 5)))
rgba_colors = [cm.jet(n) for n in np.linspace(0, 1, len(df))]
axes = df.plot(kind="kde", colormap=colormap, subplots=True)
for ax, c in zip(axes, rgba_colors):
for ax, c in zip(axes, rgba_colors, strict=True):
_check_colors(ax.get_lines(), linecolors=[c])

def test_kde_colors_and_styles_subplots_single_col(self):
Expand All @@ -586,7 +586,7 @@ def test_kde_colors_and_styles_subplots_list(self):
# list of styles
styles = list("rgcby")
axes = df.plot(kind="kde", style=styles, subplots=True)
for ax, c in zip(axes, styles):
for ax, c in zip(axes, styles, strict=True):
_check_colors(ax.get_lines(), linecolors=[c])

def test_boxplot_colors(self):
Expand Down Expand Up @@ -715,7 +715,7 @@ def test_colors_of_columns_with_same_name(self):
result = df_concat.plot()
legend = result.get_legend()
handles = legend.legend_handles
for legend, line in zip(handles, result.lines):
for legend, line in zip(handles, result.lines, strict=True):
assert legend.get_color() == line.get_color()

def test_invalid_colormap(self):
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/plotting/frame/test_frame_groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

class TestDataFramePlotsGroupby:
def _assert_ytickslabels_visibility(self, axes, expected):
for ax, exp in zip(axes, expected):
for ax, exp in zip(axes, expected, strict=True):
_check_visible(ax.get_yticklabels(), visible=exp)

def _assert_xtickslabels_visibility(self, axes, expected):
for ax, exp in zip(axes, expected):
for ax, exp in zip(axes, expected, strict=True):
_check_visible(ax.get_xticklabels(), visible=exp)

@pytest.mark.parametrize(
Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/plotting/test_boxplot_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ def test_boxplot_legacy1_return_type(self, hist_df):

@pytest.mark.slow
def test_boxplot_legacy2(self):
tuples = zip(string.ascii_letters[:10], range(10))
tuples = zip(string.ascii_letters[:10], range(10), strict=True)
df = DataFrame(
np.random.default_rng(2).random((10, 3)),
index=MultiIndex.from_tuples(tuples),
Expand All @@ -435,7 +435,7 @@ def test_boxplot_legacy2(self):

@pytest.mark.slow
def test_boxplot_legacy2_return_type(self):
tuples = zip(string.ascii_letters[:10], range(10))
tuples = zip(string.ascii_letters[:10], range(10), strict=True)
df = DataFrame(
np.random.default_rng(2).random((10, 3)),
index=MultiIndex.from_tuples(tuples),
Expand Down Expand Up @@ -744,7 +744,7 @@ def test_boxplot_multiindex_column(self):
["bar", "bar", "baz", "baz", "foo", "foo", "qux", "qux"],
["one", "two", "one", "two", "one", "two", "one", "two"],
]
tuples = list(zip(*arrays))
tuples = list(zip(*arrays, strict=True))
index = MultiIndex.from_tuples(tuples, names=["first", "second"])
df = DataFrame(
np.random.default_rng(2).standard_normal((3, 8)),
Expand Down
10 changes: 5 additions & 5 deletions pandas/tests/plotting/test_datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def test_irregular_datetime64_repr_bug(self):
ret = ser.plot(ax=ax)
assert ret is not None

for rs, xp in zip(ax.get_lines()[0].get_xdata(), ser.index):
for rs, xp in zip(ax.get_lines()[0].get_xdata(), ser.index, strict=True):
assert rs == xp

def test_business_freq(self):
Expand Down Expand Up @@ -1150,7 +1150,7 @@ def test_time(self):
# verify tick labels
ticks = ax.get_xticks()
labels = ax.get_xticklabels()
for _tick, _label in zip(ticks, labels):
for _tick, _label in zip(ticks, labels, strict=True):
m, s = divmod(int(_tick), 60)
h, m = divmod(m, 60)
rs = _label.get_text()
Expand Down Expand Up @@ -1178,7 +1178,7 @@ def test_time_change_xlim(self):
# verify tick labels
ticks = ax.get_xticks()
labels = ax.get_xticklabels()
for _tick, _label in zip(ticks, labels):
for _tick, _label in zip(ticks, labels, strict=True):
m, s = divmod(int(_tick), 60)
h, m = divmod(m, 60)
rs = _label.get_text()
Expand All @@ -1195,7 +1195,7 @@ def test_time_change_xlim(self):
# check tick labels again
ticks = ax.get_xticks()
labels = ax.get_xticklabels()
for _tick, _label in zip(ticks, labels):
for _tick, _label in zip(ticks, labels, strict=True):
m, s = divmod(int(_tick), 60)
h, m = divmod(m, 60)
rs = _label.get_text()
Expand Down Expand Up @@ -1223,7 +1223,7 @@ def test_time_musec(self):
# verify tick labels
ticks = ax.get_xticks()
labels = ax.get_xticklabels()
for _tick, _label in zip(ticks, labels):
for _tick, _label in zip(ticks, labels, strict=True):
m, s = divmod(int(_tick), 60)

us = round((_tick - int(_tick)) * 1e6)
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/plotting/test_groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def test_groupby_hist_frame_with_legend(self, column, expected_axes_num):

for axes in g.hist(legend=True, column=column):
_check_axes_shape(axes, axes_num=expected_axes_num, layout=expected_layout)
for ax, expected_label in zip(axes[0], expected_labels):
for ax, expected_label in zip(axes[0], expected_labels, strict=True):
_check_legend_labels(ax, expected_label)

@pytest.mark.parametrize("column", [None, "b"])
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/plotting/test_hist_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ def test_hist_with_legend(self, by, column):
_check_axes_shape(axes, axes_num=expected_axes_num, layout=expected_layout)
if by is None and column is None:
axes = axes[0]
for expected_label, ax in zip(expected_labels, axes):
for expected_label, ax in zip(expected_labels, axes, strict=True):
_check_legend_labels(ax, expected_label)

@pytest.mark.parametrize("by", [None, "c"])
Expand Down Expand Up @@ -644,7 +644,7 @@ def test_hist_with_nans_and_weights(self):
x for x in ax1.get_children() if isinstance(x, mpl.patches.Rectangle)
]
no_nan_heights = [rect.get_height() for rect in no_nan_rects]
assert all(h0 == h1 for h0, h1 in zip(heights, no_nan_heights))
assert all(h0 == h1 for h0, h1 in zip(heights, no_nan_heights, strict=True))

idxerror_weights = np.array([[0.3, 0.25], [0.45, 0.45]])

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/plotting/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ def test_pie_series_autopct_and_fontsize(self):
series.plot.pie, colors=color_args, autopct="%.2f", fontsize=7
)
pcts = [f"{s * 100:.2f}" for s in series.values / series.sum()]
expected_texts = list(chain.from_iterable(zip(series.index, pcts)))
expected_texts = list(chain.from_iterable(zip(series.index, pcts, strict=True)))
_check_text_labels(ax.texts, expected_texts)
for t in ax.texts:
assert t.get_fontsize() == 7
Expand Down
Loading