Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Use mplDeprecation class for all deprecations. #7723

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
Jan 2, 2017
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
24 changes: 16 additions & 8 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -898,17 +898,21 @@ def __setitem__(self, key, val):
try:
if key in _deprecated_map:
alt_key, alt_val, inverse_alt = _deprecated_map[key]
warnings.warn(self.msg_depr % (key, alt_key))
warnings.warn(self.msg_depr % (key, alt_key),
mplDeprecation)
key = alt_key
val = alt_val(val)
elif key in _deprecated_set and val is not None:
warnings.warn(self.msg_depr_set % key)
warnings.warn(self.msg_depr_set % key,
mplDeprecation)
elif key in _deprecated_ignore_map:
alt = _deprecated_ignore_map[key]
warnings.warn(self.msg_depr_ignore % (key, alt))
warnings.warn(self.msg_depr_ignore % (key, alt),
mplDeprecation)
return
elif key in _obsolete_set:
warnings.warn(self.msg_obsolete % (key,))
warnings.warn(self.msg_obsolete % (key, ),
mplDeprecation)
return
try:
cval = self.validate[key](val)
Expand All @@ -924,16 +928,19 @@ def __getitem__(self, key):
inverse_alt = None
if key in _deprecated_map:
alt_key, alt_val, inverse_alt = _deprecated_map[key]
warnings.warn(self.msg_depr % (key, alt_key))
warnings.warn(self.msg_depr % (key, alt_key),
mplDeprecation)
key = alt_key

elif key in _deprecated_ignore_map:
alt = _deprecated_ignore_map[key]
warnings.warn(self.msg_depr_ignore % (key, alt))
warnings.warn(self.msg_depr_ignore % (key, alt),
mplDeprecation)
key = alt

elif key in _obsolete_set:
warnings.warn(self.msg_obsolete % (key,))
warnings.warn(self.msg_obsolete % (key, ),
mplDeprecation)
return None

val = dict.__getitem__(self, key)
Expand Down Expand Up @@ -1092,7 +1099,8 @@ def _rc_params_in_file(fname, fail_on_error=False):
(val, error_details, msg))
elif key in _deprecated_ignore_map:
warnings.warn('%s is deprecated. Update your matplotlibrc to use '
'%s instead.' % (key, _deprecated_ignore_map[key]))
'%s instead.' % (key, _deprecated_ignore_map[key]),
mplDeprecation)

else:
print("""
Expand Down
26 changes: 18 additions & 8 deletions lib/matplotlib/rcsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
except ImportError:
# python 2
import collections as abc

from matplotlib.cbook import mplDeprecation
from matplotlib.fontconfig_pattern import parse_fontconfig_pattern
from matplotlib.colors import is_color_like

Expand Down Expand Up @@ -149,7 +151,8 @@ def deprecate_axes_hold(value):
if value is None:
return None # converted to True where accessed in figure.py,
# axes/_base.py
warnings.warn("axes.hold is deprecated, will be removed in 3.0")
warnings.warn("axes.hold is deprecated, will be removed in 3.0",
mplDeprecation)
return validate_bool(value)


Expand Down Expand Up @@ -284,7 +287,8 @@ def validate_maskedarray(v):
except ValueError:
pass
warnings.warn('rcParams key "maskedarray" is obsolete and has no effect;\n'
' please delete it from your matplotlibrc file')
' please delete it from your matplotlibrc file',
mplDeprecation)


_seq_err_msg = ('You must supply exactly {n} values, you provided {num} '
Expand Down Expand Up @@ -405,7 +409,8 @@ def validate_color(s):

def deprecate_axes_colorcycle(value):
warnings.warn("axes.color_cycle is deprecated. Use axes.prop_cycle "
"instead. Will be removed in 2.1.0")
"instead. Will be removed in 2.1.0",
mplDeprecation)
return validate_colorlist(value)


Expand Down Expand Up @@ -480,7 +485,8 @@ def validate_whiskers(s):

def deprecate_savefig_extension(value):
warnings.warn("savefig.extension is deprecated. Use savefig.format "
"instead. Will be removed in 1.4.x")
"instead. Will be removed in 1.4.x",
mplDeprecation)
return value


Expand Down Expand Up @@ -541,7 +547,8 @@ def validate_negative_linestyle_legacy(s):
except ValueError:
dashes = validate_nseq_float(2)(s)
warnings.warn("Deprecated negative_linestyle specification; use "
"'solid' or 'dashed'")
"'solid' or 'dashed'",
mplDeprecation)
return (0, dashes) # (offset, (solid, blank))


Expand All @@ -554,7 +561,8 @@ def validate_corner_mask(s):

def validate_tkpythoninspect(s):
# Introduced 2010/07/05
warnings.warn("tk.pythoninspect is obsolete, and has no effect")
warnings.warn("tk.pythoninspect is obsolete, and has no effect",
mplDeprecation)
return validate_bool(s)

validate_legend_loc = ValidateInStrings(
Expand All @@ -574,12 +582,14 @@ def validate_tkpythoninspect(s):

def deprecate_svg_image_noscale(value):
warnings.warn("svg.image_noscale is deprecated. Set "
"image.interpolation to 'none' instead.")
"image.interpolation to 'none' instead.",
mplDeprecation)


def deprecate_svg_embed_char_paths(value):
warnings.warn("svg.embed_char_paths is deprecated. Use "
"svg.fonttype instead.")
"svg.fonttype instead.",
mplDeprecation)


validate_svg_fonttype = ValidateInStrings('svg.fonttype',
Expand Down