Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 82f7254

Browse filesBrowse files
authored
Merge pull request #29170 from meeseeksmachine/auto-backport-of-pr-29154-on-v3.10.x
Backport PR #29154 on branch v3.10.x (Relax conditions for warning on updating converters)
2 parents 5d62c9e + cc0188e commit 82f7254
Copy full SHA for 82f7254

File tree

Expand file treeCollapse file tree

2 files changed

+16
-4
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+16
-4
lines changed

‎lib/matplotlib/axis.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axis.py
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1842,11 +1842,15 @@ def set_converter(self, converter):
18421842
self._converter_is_explicit = True
18431843

18441844
def _set_converter(self, converter):
1845-
if self._converter == converter:
1845+
if self._converter is converter or self._converter == converter:
18461846
return
18471847
if self._converter_is_explicit:
18481848
raise RuntimeError("Axis already has an explicit converter set")
1849-
elif self._converter is not None:
1849+
elif (
1850+
self._converter is not None and
1851+
not isinstance(converter, type(self._converter)) and
1852+
not isinstance(self._converter, type(converter))
1853+
):
18501854
_api.warn_external(
18511855
"This axis already has a converter set and "
18521856
"is updating to a potentially incompatible converter"

‎lib/matplotlib/tests/test_units.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_units.py
+10-2Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from matplotlib.testing.decorators import check_figures_equal, image_comparison
77
import matplotlib.units as munits
88
from matplotlib.category import StrCategoryConverter, UnitData
9+
from matplotlib.dates import DateConverter
910
import numpy as np
1011
import pytest
1112

@@ -240,6 +241,7 @@ def test_explicit_converter():
240241
d1 = {"a": 1, "b": 2}
241242
str_cat_converter = StrCategoryConverter()
242243
str_cat_converter_2 = StrCategoryConverter()
244+
date_converter = DateConverter()
243245

244246
# Explicit is set
245247
fig1, ax1 = plt.subplots()
@@ -254,12 +256,18 @@ def test_explicit_converter():
254256
with pytest.raises(RuntimeError):
255257
ax1.xaxis.set_converter(str_cat_converter_2)
256258

257-
# Warn when implicit overridden
258259
fig2, ax2 = plt.subplots()
259260
ax2.plot(d1.keys(), d1.values())
260261

262+
# No error when equivalent type is used
263+
ax2.xaxis.set_converter(str_cat_converter)
264+
265+
fig3, ax3 = plt.subplots()
266+
ax3.plot(d1.keys(), d1.values())
267+
268+
# Warn when implicit overridden
261269
with pytest.warns():
262-
ax2.xaxis.set_converter(str_cat_converter)
270+
ax3.xaxis.set_converter(date_converter)
263271

264272

265273
def test_empty_default_limits(quantity_converter):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.