Skip to content

Remove some APIs deprecated in mpl3.1. #16477

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/api/next_api_changes/removals.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ Classes and methods
- ``dates.minutes()`` (no replacement)
- ``dates.hours()`` (no replacement)
- ``dates.weeks()`` (no replacement)
- ``dates.strpdate2num`` and ``dates.bytespdate2num`` (use `time.strptime` or
`dateutil.parser.parse` or `.dates.datestr2num` instead)

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

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

Environment variables
~~~~~~~~~~~~~~~~~~~~~
Expand Down
4 changes: 2 additions & 2 deletions doc/api/prev_api_changes/api_changes_3.1.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -915,8 +915,8 @@ Date related functions
- ``dates.minutes()``
- ``dates.hours()``
- ``dates.weeks()``
- `.dates.strpdate2num`
- `.dates.bytespdate2num`
- ``dates.strpdate2num``
- ``dates.bytespdate2num``

These are brittle in the presence of locale changes. Use standard datetime
parsers such as `time.strptime` or `dateutil.parser.parse`, and additionally
Expand Down
62 changes: 0 additions & 62 deletions lib/matplotlib/dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@
import logging
import math
import re
import time

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


@cbook.deprecated(
"3.1", alternative="time.strptime or dateutil.parser.parse or datestr2num")
class strpdate2num:
"""
Use this class to parse date strings to matplotlib datenums when
you know the date format string of the date you are parsing.
"""
def __init__(self, fmt):
"""
Parameters
----------
fmt : any valid strptime format
"""
self.fmt = fmt

def __call__(self, s):
"""
Parameters
----------
s : str

Returns
-------
date2num float
"""
return date2num(datetime.datetime(*time.strptime(s, self.fmt)[:6]))


@cbook.deprecated(
"3.1", alternative="time.strptime or dateutil.parser.parse or datestr2num")
class bytespdate2num(strpdate2num):
"""
Use this class to parse date strings to matplotlib datenums when
you know the date format string of the date you are parsing. See
:doc:`/gallery/misc/load_converter.py`.
"""
def __init__(self, fmt, encoding='utf-8'):
"""
Parameters
----------
fmt : any valid strptime format
encoding : str
Encoding to use on byte input.
"""
super().__init__(fmt)
self.encoding = encoding

def __call__(self, b):
"""
Parameters
----------
b : bytes

Returns
-------
date2num float
"""
s = b.decode(self.encoding)
return super().__call__(s)


# a version of dateutil.parser.parse that can operate on numpy arrays
_dateutil_parser_parse_np_vectorized = np.vectorize(dateutil.parser.parse)

Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/pylab.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import matplotlib as mpl

from matplotlib.dates import (
date2num, num2date, datestr2num, strpdate2num, drange, epoch2num,
date2num, num2date, datestr2num, drange, epoch2num,
num2epoch, mx2num, DateFormatter, IndexDateFormatter, DateLocator,
RRuleLocator, YearLocator, MonthLocator, WeekdayLocator, DayLocator,
HourLocator, MinuteLocator, SecondLocator, rrule, MO, TU, WE, TH, FR,
Expand Down
13 changes: 2 additions & 11 deletions lib/matplotlib/rcsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,17 +422,8 @@ def validate_font_properties(s):
validate_fontset = ValidateInStrings(
'fontset',
['dejavusans', 'dejavuserif', 'cm', 'stix', 'stixsans', 'custom'])


def validate_mathtext_default(s):
if s == "circled":
cbook.warn_deprecated(
"3.1", message="Support for setting the mathtext.default rcParam "
"to 'circled' is deprecated since %(since)s and will be removed "
"%(removal)s.")
return ValidateInStrings(
'default',
"rm cal it tt sf bf default bb frak circled scr regular".split())(s)
validate_mathtext_default = ValidateInStrings(
'default', "rm cal it tt sf bf default bb frak scr regular".split())


_validate_alignment = ValidateInStrings(
Expand Down