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 da9533d

Browse filesBrowse files
authored
Merge pull request #22719 from oscargus/incorrectdeprecationwarning
Fix incorrect deprecation warning
2 parents a395083 + c0a384e commit da9533d
Copy full SHA for da9533d

File tree

2 files changed

+11
-2
lines changed
Filter options

2 files changed

+11
-2
lines changed

‎lib/matplotlib/category.py

Copy file name to clipboardExpand all lines: lib/matplotlib/category.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def convert(value, unit, axis):
5858
is_numlike = all(units.ConversionInterface.is_numlike(v)
5959
and not isinstance(v, (str, bytes))
6060
for v in values)
61-
if is_numlike:
61+
if values.size and is_numlike:
6262
_api.warn_deprecated(
6363
"3.5", message="Support for passing numbers through unit "
6464
"converters is deprecated since %(since)s and support will be "
@@ -230,7 +230,7 @@ def update(self, data):
230230
convertible = self._str_is_convertible(val)
231231
if val not in self._mapping:
232232
self._mapping[val] = next(self._counter)
233-
if convertible:
233+
if data.size and convertible:
234234
_log.info('Using categorical units to plot a list of strings '
235235
'that are all parsable as floats or dates. If these '
236236
'strings should be plotted as numbers, cast to the '

‎lib/matplotlib/tests/test_category.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_category.py
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,15 @@ def test_overriding_units_in_plot(fig_test, fig_ref):
307307
assert y_units is ax.yaxis.units
308308

309309

310+
def test_no_deprecation_on_empty_data():
311+
"""
312+
Smoke test to check that no deprecation warning is emitted. See #22640.
313+
"""
314+
f, ax = plt.subplots()
315+
ax.xaxis.update_units(["a", "b"])
316+
ax.plot([], [])
317+
318+
310319
def test_hist():
311320
fig, ax = plt.subplots()
312321
n, bins, patches = ax.hist(['a', 'b', 'a', 'c', 'ff'])

0 commit comments

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