Skip to content

Commit 50d2fd3

Browse files
committed
Remove version workarounds
1 parent fda510d commit 50d2fd3

File tree

5 files changed

+7
-39
lines changed

5 files changed

+7
-39
lines changed

pandas/plotting/_matplotlib/core.py

+2-11
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
from pandas.core.dtypes.missing import isna
5656

5757
import pandas.core.common as com
58-
from pandas.util.version import Version
5958

6059
from pandas.io.formats.printing import pprint_thing
6160
from pandas.plotting._matplotlib import tools
@@ -872,10 +871,7 @@ def _make_legend(self) -> None:
872871
if leg is not None:
873872
title = leg.get_title().get_text()
874873
# Replace leg.legend_handles because it misses marker info
875-
if Version(mpl.__version__) < Version("3.7"):
876-
handles = leg.legendHandles
877-
else:
878-
handles = leg.legend_handles
874+
handles = leg.legend_handles
879875
labels = [x.get_text() for x in leg.get_texts()]
880876

881877
if self.legend:
@@ -1213,15 +1209,10 @@ def _get_errorbars(
12131209

12141210
@final
12151211
def _get_subplots(self, fig: Figure) -> list[Axes]:
1216-
if Version(mpl.__version__) < Version("3.8"):
1217-
Klass = mpl.axes.Subplot
1218-
else:
1219-
Klass = mpl.axes.Axes
1220-
12211212
return [
12221213
ax
12231214
for ax in fig.get_axes()
1224-
if (isinstance(ax, Klass) and ax.get_subplotspec() is not None)
1215+
if (isinstance(ax, mpl.axes.Axes) and ax.get_subplotspec() is not None)
12251216
]
12261217

12271218
@final

pandas/tests/io/test_spss.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,9 @@ def test_spss_metadata(datapath):
169169
"variable_measure": {"VAR00002": "unknown"},
170170
"file_label": None,
171171
"file_format": "sav/zsav",
172+
"creation_time": datetime.datetime(2015, 2, 6, 14, 33, 36),
173+
"modification_time": datetime.datetime(2015, 2, 6, 14, 33, 36),
172174
}
173-
if Version(pyreadstat.__version__) >= Version("1.2.4"):
174-
metadata.update(
175-
{
176-
"creation_time": datetime.datetime(2015, 2, 6, 14, 33, 36),
177-
"modification_time": datetime.datetime(2015, 2, 6, 14, 33, 36),
178-
}
179-
)
180175
if Version(pyreadstat.__version__) >= Version("1.2.8"):
181176
metadata["mr_sets"] = {}
182177
tm.assert_dict_equal(df.attrs, metadata)

pandas/tests/io/test_sql.py

-7
Original file line numberDiff line numberDiff line change
@@ -3402,13 +3402,6 @@ def test_to_sql_with_negative_npinf(conn, request, input):
34023402
# GH 36465
34033403
# The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error
34043404
# for pymysql version >= 0.10
3405-
# TODO(GH#36465): remove this version check after GH 36465 is fixed
3406-
pymysql = pytest.importorskip("pymysql")
3407-
3408-
if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns:
3409-
mark = pytest.mark.xfail(reason="GH 36465")
3410-
request.applymarker(mark)
3411-
34123405
msg = "inf cannot be used with MySQL"
34133406
with pytest.raises(ValueError, match=msg):
34143407
df.to_sql(name="foobar", con=conn, index=False)

pandas/tests/plotting/frame/test_frame_color.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
_check_plot_works,
1414
_unpack_cycler,
1515
)
16-
from pandas.util.version import Version
1716

1817
mpl = pytest.importorskip("matplotlib")
1918
plt = pytest.importorskip("matplotlib.pyplot")
@@ -715,10 +714,7 @@ def test_colors_of_columns_with_same_name(self):
715714
df_concat = pd.concat([df, df1], axis=1)
716715
result = df_concat.plot()
717716
legend = result.get_legend()
718-
if Version(mpl.__version__) < Version("3.7"):
719-
handles = legend.legendHandles
720-
else:
721-
handles = legend.legend_handles
717+
handles = legend.legend_handles
722718
for legend, line in zip(handles, result.lines):
723719
assert legend.get_color() == line.get_color()
724720

pandas/tests/plotting/frame/test_frame_legend.py

+2-9
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
_check_legend_marker,
1313
_check_text_labels,
1414
)
15-
from pandas.util.version import Version
1615

1716
mpl = pytest.importorskip("matplotlib")
1817

@@ -32,10 +31,7 @@ def test_mixed_yerr(self):
3231
df.plot("x", "b", c="blue", yerr=None, ax=ax, label="blue")
3332

3433
legend = ax.get_legend()
35-
if Version(mpl.__version__) < Version("3.7"):
36-
result_handles = legend.legendHandles
37-
else:
38-
result_handles = legend.legend_handles
34+
result_handles = legend.legend_handles
3935

4036
assert isinstance(result_handles[0], mpl.collections.LineCollection)
4137
assert isinstance(result_handles[1], mpl.lines.Line2D)
@@ -48,10 +44,7 @@ def test_legend_false(self):
4844
ax = df.plot(legend=True, color={"a": "blue", "b": "green"}, secondary_y="b")
4945
df2.plot(legend=True, color={"d": "red"}, ax=ax)
5046
legend = ax.get_legend()
51-
if Version(mpl.__version__) < Version("3.7"):
52-
handles = legend.legendHandles
53-
else:
54-
handles = legend.legend_handles
47+
handles = legend.legend_handles
5548
result = [handle.get_color() for handle in handles]
5649
expected = ["blue", "green", "red"]
5750
assert result == expected

0 commit comments

Comments
 (0)