diff --git a/pandas/tests/plotting/common.py b/pandas/tests/plotting/common.py index d8c49d6d47f28..588bbf88e8562 100644 --- a/pandas/tests/plotting/common.py +++ b/pandas/tests/plotting/common.py @@ -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) @@ -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 @@ -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] @@ -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 diff --git a/pandas/tests/plotting/frame/test_frame_color.py b/pandas/tests/plotting/frame/test_frame_color.py index 5e5c3539f3283..96adf8e5bb8c9 100644 --- a/pandas/tests/plotting/frame/test_frame_color.py +++ b/pandas/tests/plotting/frame/test_frame_color.py @@ -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]) @@ -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): @@ -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]) @@ -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): @@ -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): @@ -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]) @@ -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): @@ -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): @@ -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): diff --git a/pandas/tests/plotting/frame/test_frame_groupby.py b/pandas/tests/plotting/frame/test_frame_groupby.py index b7e147bbabde5..89589f5adbbc0 100644 --- a/pandas/tests/plotting/frame/test_frame_groupby.py +++ b/pandas/tests/plotting/frame/test_frame_groupby.py @@ -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( diff --git a/pandas/tests/plotting/test_boxplot_method.py b/pandas/tests/plotting/test_boxplot_method.py index 2267b6197cd80..09d0d42b20d76 100644 --- a/pandas/tests/plotting/test_boxplot_method.py +++ b/pandas/tests/plotting/test_boxplot_method.py @@ -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), @@ -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), @@ -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)), diff --git a/pandas/tests/plotting/test_datetimelike.py b/pandas/tests/plotting/test_datetimelike.py index 5c2a31b8bc548..8af3c9d996475 100644 --- a/pandas/tests/plotting/test_datetimelike.py +++ b/pandas/tests/plotting/test_datetimelike.py @@ -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): @@ -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() @@ -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() @@ -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() @@ -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) diff --git a/pandas/tests/plotting/test_groupby.py b/pandas/tests/plotting/test_groupby.py index 0cb125d822fd1..e86c4e9838d24 100644 --- a/pandas/tests/plotting/test_groupby.py +++ b/pandas/tests/plotting/test_groupby.py @@ -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"]) diff --git a/pandas/tests/plotting/test_hist_method.py b/pandas/tests/plotting/test_hist_method.py index 410b658065d8d..e71d4ce5475a8 100644 --- a/pandas/tests/plotting/test_hist_method.py +++ b/pandas/tests/plotting/test_hist_method.py @@ -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"]) @@ -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]]) diff --git a/pandas/tests/plotting/test_series.py b/pandas/tests/plotting/test_series.py index 779e539b3afba..3ef1e660236c8 100644 --- a/pandas/tests/plotting/test_series.py +++ b/pandas/tests/plotting/test_series.py @@ -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