Skip to content

Commit a0eb716

Browse files
authored
Merge pull request #16477 from anntzer/k31
Remove some APIs deprecated in mpl3.1.
2 parents ae72e62 + dd44423 commit a0eb716

File tree

5 files changed

+8
-76
lines changed

5 files changed

+8
-76
lines changed

doc/api/next_api_changes/removals.rst

+3
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ Classes and methods
8080
- ``dates.minutes()`` (no replacement)
8181
- ``dates.hours()`` (no replacement)
8282
- ``dates.weeks()`` (no replacement)
83+
- ``dates.strpdate2num`` and ``dates.bytespdate2num`` (use `time.strptime` or
84+
`dateutil.parser.parse` or `.dates.datestr2num` instead)
8385

8486
- ``font_manager.OSXInstalledFonts()`` (no replacement)
8587

@@ -150,6 +152,7 @@ rcParams
150152
:rc:`savefig.facecolor` to "none" to get a transparent background.
151153
- The ``pgf.debug``, ``verbose.fileo`` and ``verbose.verbose.level`` rcParams,
152154
which had no effect, have been removed.
155+
- Support for setting :rc:`mathtext.default` to "circled" has been removed.
153156

154157
Environment variables
155158
~~~~~~~~~~~~~~~~~~~~~

doc/api/prev_api_changes/api_changes_3.1.0.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -915,8 +915,8 @@ Date related functions
915915
- ``dates.minutes()``
916916
- ``dates.hours()``
917917
- ``dates.weeks()``
918-
- `.dates.strpdate2num`
919-
- `.dates.bytespdate2num`
918+
- ``dates.strpdate2num``
919+
- ``dates.bytespdate2num``
920920

921921
These are brittle in the presence of locale changes. Use standard datetime
922922
parsers such as `time.strptime` or `dateutil.parser.parse`, and additionally

lib/matplotlib/dates.py

-62
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@
137137
import logging
138138
import math
139139
import re
140-
import time
141140

142141
from dateutil.rrule import (rrule, MO, TU, WE, TH, FR, SA, SU, YEARLY,
143142
MONTHLY, WEEKLY, DAILY, HOURLY, MINUTELY,
@@ -308,67 +307,6 @@ def _from_ordinalf(x, tz=None):
308307
_from_ordinalf_np_vectorized = np.vectorize(_from_ordinalf, otypes="O")
309308

310309

311-
@cbook.deprecated(
312-
"3.1", alternative="time.strptime or dateutil.parser.parse or datestr2num")
313-
class strpdate2num:
314-
"""
315-
Use this class to parse date strings to matplotlib datenums when
316-
you know the date format string of the date you are parsing.
317-
"""
318-
def __init__(self, fmt):
319-
"""
320-
Parameters
321-
----------
322-
fmt : any valid strptime format
323-
"""
324-
self.fmt = fmt
325-
326-
def __call__(self, s):
327-
"""
328-
Parameters
329-
----------
330-
s : str
331-
332-
Returns
333-
-------
334-
date2num float
335-
"""
336-
return date2num(datetime.datetime(*time.strptime(s, self.fmt)[:6]))
337-
338-
339-
@cbook.deprecated(
340-
"3.1", alternative="time.strptime or dateutil.parser.parse or datestr2num")
341-
class bytespdate2num(strpdate2num):
342-
"""
343-
Use this class to parse date strings to matplotlib datenums when
344-
you know the date format string of the date you are parsing. See
345-
:doc:`/gallery/misc/load_converter.py`.
346-
"""
347-
def __init__(self, fmt, encoding='utf-8'):
348-
"""
349-
Parameters
350-
----------
351-
fmt : any valid strptime format
352-
encoding : str
353-
Encoding to use on byte input.
354-
"""
355-
super().__init__(fmt)
356-
self.encoding = encoding
357-
358-
def __call__(self, b):
359-
"""
360-
Parameters
361-
----------
362-
b : bytes
363-
364-
Returns
365-
-------
366-
date2num float
367-
"""
368-
s = b.decode(self.encoding)
369-
return super().__call__(s)
370-
371-
372310
# a version of dateutil.parser.parse that can operate on numpy arrays
373311
_dateutil_parser_parse_np_vectorized = np.vectorize(dateutil.parser.parse)
374312

lib/matplotlib/pylab.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import matplotlib as mpl
1717

1818
from matplotlib.dates import (
19-
date2num, num2date, datestr2num, strpdate2num, drange, epoch2num,
19+
date2num, num2date, datestr2num, drange, epoch2num,
2020
num2epoch, mx2num, DateFormatter, IndexDateFormatter, DateLocator,
2121
RRuleLocator, YearLocator, MonthLocator, WeekdayLocator, DayLocator,
2222
HourLocator, MinuteLocator, SecondLocator, rrule, MO, TU, WE, TH, FR,

lib/matplotlib/rcsetup.py

+2-11
Original file line numberDiff line numberDiff line change
@@ -422,17 +422,8 @@ def validate_font_properties(s):
422422
validate_fontset = ValidateInStrings(
423423
'fontset',
424424
['dejavusans', 'dejavuserif', 'cm', 'stix', 'stixsans', 'custom'])
425-
426-
427-
def validate_mathtext_default(s):
428-
if s == "circled":
429-
cbook.warn_deprecated(
430-
"3.1", message="Support for setting the mathtext.default rcParam "
431-
"to 'circled' is deprecated since %(since)s and will be removed "
432-
"%(removal)s.")
433-
return ValidateInStrings(
434-
'default',
435-
"rm cal it tt sf bf default bb frak circled scr regular".split())(s)
425+
validate_mathtext_default = ValidateInStrings(
426+
'default', "rm cal it tt sf bf default bb frak scr regular".split())
436427

437428

438429
_validate_alignment = ValidateInStrings(

0 commit comments

Comments
 (0)