Skip to content

Commit d00bc13

Browse files
committed
Improve deprecation system and warning messages
1 parent c4f9ad5 commit d00bc13

File tree

13 files changed

+198
-153
lines changed

13 files changed

+198
-153
lines changed

WHATSNEW.rst

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,20 @@
1313
What's new?
1414
===========
1515

16-
This page lists the API changes with each version. Please note that
17-
when functions and keywords are renamed, they are not removed -- requesting
18-
the old name will issue a warning rather than an error. Authors are shown next to
19-
each change. Where not indicated, `Luke Davis`_ was the author.
20-
21-
See the :ref:`author page <authors>` for a list of contributors, and see
22-
the :ref:`contribution guide <contributions>` if you are interested in
16+
This page lists the API changes with each version. Authors are shown next to
17+
each change. Where not indicated, `Luke Davis`_ was the author. See the
18+
:ref:`author page <authors>` for a list of contributors, and see the
19+
:ref:`contribution guide <contributions>` if you are interested in
2320
submitting your own changes.
2421

22+
.. important::
23+
24+
Please note that when classes, functions, keywords, or settings are deprecated,
25+
they are not removed -- using the old syntax will result in a warning rather than
26+
an error and preserve the original functionality. Since proplot adheres to `semantic
27+
versioning <https://semver.org>`__, we will not consider removing the deprecated
28+
syntax until the first major release (i.e., version 1.0.0).
29+
2530
Version 1.0.0 (2022-XX-XX)
2631
==========================
2732

docs/api.rst

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,27 @@ The comprehensive API reference. All of the below objects are imported
88
into the top-level namespace. Use ``help(pplt.object)`` to read
99
the docs during a python session.
1010

11-
Please note that the documentation for "wrapper" functions from
12-
proplot < 0.8 is now found under the individual `~proplot.axes.PlotAxes`
13-
plotting commands. Using ``help(ax.command)`` during a python session shows both
14-
the proplot documentation and the original matplotlib documentation.
11+
Please note that proplot removes the associated documentation when functionality
12+
is deprecated (see :ref:`What's New <whats_new>`). However, proplot adheres to
13+
`semantic versioning <https://semver.org>`__, which means old code that uses deprecated
14+
functionality will 1) still work and 2) issue warnings rather than errors until the
15+
first major release (i.e. version 1.0.0).
16+
17+
.. important::
18+
19+
The color transformation functions like `to_rgba` and `scale_luminance` from
20+
proplot < 0.10.0 can now be found as methods on the new `~proplot.colors.Color`
21+
class. Please see `~proplot.colors.Color` for the relevant documentation. Note that
22+
old code that uses commands like ``pplt.to_rgba()`` and ``pplt.scale_luminance()``
23+
will still work -- but it will result in a deprecation warning.
24+
25+
.. important::
26+
27+
The documentation for "wrapper" functions like `standardize_1d` and `cmap_changer`
28+
from proplot < 0.8.0 like can now be found under individual `~proplot.axes.PlotAxes`
29+
methods like `~proplot.axes.PlotAxes.pcolor`. Please see `~proplot.axes.PlotAxes` for
30+
the relevant documentation. Note that calling ``help(ax.method)`` in a python session
31+
will show both the proplot documentation and the original matplotlib documentation.
1532

1633
Figure class
1734
============

proplot/axes/plot.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2092,7 +2092,7 @@ def _parse_color(self, x, y, c, *, apply_cycle=True, infer_rgb=False, **kwargs):
20922092
warnings._warn_proplot(f'Ignoring unused keyword arg(s): {pop}')
20932093
return (c, kwargs)
20942094

2095-
@warnings._rename_kwargs('0.6', centers='values')
2095+
@warnings._rename_kwargs('0.6.0', centers='values')
20962096
def _parse_cmap(
20972097
self, *args,
20982098
cmap=None, cmap_kw=None, c=None, color=None, colors=None,
@@ -4094,5 +4094,5 @@ def _iter_arg_cols(self, *args, label=None, labels=None, values=None, **kwargs):
40944094
_level_parsers = (_parse_level_list, _parse_level_count, _parse_level_lim)
40954095

40964096
# Rename the shorthands
4097-
boxes = warnings._rename_objs('0.8', boxes=box)
4098-
violins = warnings._rename_objs('0.8', violins=violin)
4097+
boxes = warnings._rename_objs('0.8.0', boxes=box)
4098+
violins = warnings._rename_objs('0.8.0', violins=violin)

proplot/colors.py

Lines changed: 62 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -117,59 +117,59 @@
117117
):
118118
CMAPS_DIVERGING[_cmap_diverging.lower()] = _cmap_diverging.lower()
119119
CMAPS_REMOVED = {
120-
'Blue0': '0.6',
121-
'Cool': '0.6',
122-
'Warm': '0.6',
123-
'Hot': '0.6',
124-
'Floral': '0.6',
125-
'Contrast': '0.6',
126-
'Sharp': '0.6',
127-
'Viz': '0.6',
120+
'Blue0': '0.6.0',
121+
'Cool': '0.6.0',
122+
'Warm': '0.6.0',
123+
'Hot': '0.6.0',
124+
'Floral': '0.6.0',
125+
'Contrast': '0.6.0',
126+
'Sharp': '0.6.0',
127+
'Viz': '0.6.0',
128128
}
129129
CMAPS_RENAMED = {
130-
'GrayCycle': ('MonoCycle', '0.6'),
131-
'Blue1': ('Blues1', '0.7'),
132-
'Blue2': ('Blues2', '0.7'),
133-
'Blue3': ('Blues3', '0.7'),
134-
'Blue4': ('Blues4', '0.7'),
135-
'Blue5': ('Blues5', '0.7'),
136-
'Blue6': ('Blues6', '0.7'),
137-
'Blue7': ('Blues7', '0.7'),
138-
'Blue8': ('Blues8', '0.7'),
139-
'Blue9': ('Blues9', '0.7'),
140-
'Green1': ('Greens1', '0.7'),
141-
'Green2': ('Greens2', '0.7'),
142-
'Green3': ('Greens3', '0.7'),
143-
'Green4': ('Greens4', '0.7'),
144-
'Green5': ('Greens5', '0.7'),
145-
'Green6': ('Greens6', '0.7'),
146-
'Green7': ('Greens7', '0.7'),
147-
'Green8': ('Greens8', '0.7'),
148-
'Orange1': ('Yellows1', '0.7'),
149-
'Orange2': ('Yellows2', '0.7'),
150-
'Orange3': ('Yellows3', '0.7'),
151-
'Orange4': ('Oranges2', '0.7'),
152-
'Orange5': ('Oranges1', '0.7'),
153-
'Orange6': ('Oranges3', '0.7'),
154-
'Orange7': ('Oranges4', '0.7'),
155-
'Orange8': ('Yellows4', '0.7'),
156-
'Brown1': ('Browns1', '0.7'),
157-
'Brown2': ('Browns2', '0.7'),
158-
'Brown3': ('Browns3', '0.7'),
159-
'Brown4': ('Browns4', '0.7'),
160-
'Brown5': ('Browns5', '0.7'),
161-
'Brown6': ('Browns6', '0.7'),
162-
'Brown7': ('Browns7', '0.7'),
163-
'Brown8': ('Browns8', '0.7'),
164-
'Brown9': ('Browns9', '0.7'),
165-
'RedPurple1': ('Reds1', '0.7'),
166-
'RedPurple2': ('Reds2', '0.7'),
167-
'RedPurple3': ('Reds3', '0.7'),
168-
'RedPurple4': ('Reds4', '0.7'),
169-
'RedPurple5': ('Reds5', '0.7'),
170-
'RedPurple6': ('Purples1', '0.7'),
171-
'RedPurple7': ('Purples2', '0.7'),
172-
'RedPurple8': ('Purples3', '0.7'),
130+
'GrayCycle': ('MonoCycle', '0.6.0'),
131+
'Blue1': ('Blues1', '0.7.0'),
132+
'Blue2': ('Blues2', '0.7.0'),
133+
'Blue3': ('Blues3', '0.7.0'),
134+
'Blue4': ('Blues4', '0.7.0'),
135+
'Blue5': ('Blues5', '0.7.0'),
136+
'Blue6': ('Blues6', '0.7.0'),
137+
'Blue7': ('Blues7', '0.7.0'),
138+
'Blue8': ('Blues8', '0.7.0'),
139+
'Blue9': ('Blues9', '0.7.0'),
140+
'Green1': ('Greens1', '0.7.0'),
141+
'Green2': ('Greens2', '0.7.0'),
142+
'Green3': ('Greens3', '0.7.0'),
143+
'Green4': ('Greens4', '0.7.0'),
144+
'Green5': ('Greens5', '0.7.0'),
145+
'Green6': ('Greens6', '0.7.0'),
146+
'Green7': ('Greens7', '0.7.0'),
147+
'Green8': ('Greens8', '0.7.0'),
148+
'Orange1': ('Yellows1', '0.7.0'),
149+
'Orange2': ('Yellows2', '0.7.0'),
150+
'Orange3': ('Yellows3', '0.7.0'),
151+
'Orange4': ('Oranges2', '0.7.0'),
152+
'Orange5': ('Oranges1', '0.7.0'),
153+
'Orange6': ('Oranges3', '0.7.0'),
154+
'Orange7': ('Oranges4', '0.7.0'),
155+
'Orange8': ('Yellows4', '0.7.0'),
156+
'Brown1': ('Browns1', '0.7.0'),
157+
'Brown2': ('Browns2', '0.7.0'),
158+
'Brown3': ('Browns3', '0.7.0'),
159+
'Brown4': ('Browns4', '0.7.0'),
160+
'Brown5': ('Browns5', '0.7.0'),
161+
'Brown6': ('Browns6', '0.7.0'),
162+
'Brown7': ('Browns7', '0.7.0'),
163+
'Brown8': ('Browns8', '0.7.0'),
164+
'Brown9': ('Browns9', '0.7.0'),
165+
'RedPurple1': ('Reds1', '0.7.0'),
166+
'RedPurple2': ('Reds2', '0.7.0'),
167+
'RedPurple3': ('Reds3', '0.7.0'),
168+
'RedPurple4': ('Reds4', '0.7.0'),
169+
'RedPurple5': ('Reds5', '0.7.0'),
170+
'RedPurple6': ('Purples1', '0.7.0'),
171+
'RedPurple7': ('Purples2', '0.7.0'),
172+
'RedPurple8': ('Purples3', '0.7.0'),
173173
}
174174

175175
# Color constants
@@ -1584,11 +1584,11 @@ def from_list(cls, *args, **kwargs):
15841584

15851585
# Deprecated
15861586
to_listed = warnings._rename_objs(
1587-
'0.8',
1587+
'0.8.0',
15881588
to_listed=to_discrete
15891589
)
15901590
concatenate, punched, truncated, updated = warnings._rename_objs(
1591-
'0.6',
1591+
'0.6.0',
15921592
concatenate=append,
15931593
punched=cut,
15941594
truncated=truncate,
@@ -1864,7 +1864,7 @@ def from_file(cls, path, *, warn_on_failure=False):
18641864

18651865
# Rename methods
18661866
concatenate, truncated, updated = warnings._rename_objs(
1867-
'0.6',
1867+
'0.6.0',
18681868
concatenate=append,
18691869
truncated=truncate,
18701870
updated=copy,
@@ -2077,7 +2077,7 @@ def to_continuous(self, name=None, **kwargs):
20772077

20782078
@classmethod
20792079
@docstring._snippet_manager
2080-
@warnings._rename_kwargs('0.7', fade='saturation', shade='luminance')
2080+
@warnings._rename_kwargs('0.7.0', fade='saturation', shade='luminance')
20812081
def from_color(cls, *args, **kwargs):
20822082
"""
20832083
Return a simple monochromatic "sequential" colormap that blends from white
@@ -2272,7 +2272,7 @@ def from_list(cls, *args, adjust_grays=True, **kwargs):
22722272

22732273
# Deprecated
22742274
to_linear_segmented = warnings._rename_objs(
2275-
'0.8',
2275+
'0.8.0',
22762276
to_linear_segmented=to_continuous
22772277
)
22782278

@@ -2341,7 +2341,7 @@ class DiscreteNorm(mcolors.BoundaryNorm):
23412341
# test for class membership, crucially including _process_values(), which
23422342
# if it doesn't detect BoundaryNorm will try to use DiscreteNorm.inverse().
23432343
@warnings._rename_kwargs(
2344-
'0.7', extend='unique', descending='DiscreteNorm(descending_levels)'
2344+
'0.7.0', extend='unique', descending='DiscreteNorm(descending_levels)'
23452345
)
23462346
def __init__(self, levels, norm=None, unique=None, step=None, clip=False):
23472347
"""
@@ -3026,13 +3026,14 @@ def _translate_deprecated(self, key):
30263026
if not self._has_item(test) and test in CMAPS_REMOVED:
30273027
version = CMAPS_REMOVED[test]
30283028
raise ValueError(
3029-
f'Proplot colormap {key!r} was removed in version {version}.'
3029+
f'The colormap name {key!r} was removed in version {version}.'
30303030
)
30313031
if not self._has_item(test) and test in CMAPS_RENAMED:
30323032
test_new, version = CMAPS_RENAMED[test]
30333033
warnings._warn_proplot(
3034-
f'Colormap {test!r} was renamed in version {version} and will be '
3035-
f'removed in a future release. Please use {test_new!r} instead.' # noqa: E501
3034+
f'The colormap name {test!r} was deprecated in version {version} '
3035+
f'and may be removed in {warnings._next_release()}. Please use '
3036+
f'the colormap name {test_new!r} instead.'
30363037
)
30373038
key = re.sub(test, test_new, key, flags=re.IGNORECASE)
30383039
return key
@@ -3118,7 +3119,7 @@ def _set_item(self, key, value):
31183119
PerceptuallyUniformColormap,
31193120
LinearSegmentedNorm,
31203121
) = warnings._rename_objs( # noqa: E501
3121-
'0.8',
3122+
'0.8.0',
31223123
ListedColormap=DiscreteColormap,
31233124
LinearSegmentedColormap=ContinuousColormap,
31243125
PerceptuallyUniformColormap=PerceptualColormap,

proplot/config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1743,7 +1743,7 @@ def changed(self):
17431743
return _filter_style_dict(rcdict, warn=False)
17441744

17451745
# Renamed methods
1746-
load_file = warnings._rename_objs('0.8', load_file=load)
1746+
load_file = warnings._rename_objs('0.8.0', load_file=load)
17471747

17481748

17491749
# Initialize locations
@@ -1764,8 +1764,8 @@ def changed(self):
17641764

17651765
# Deprecated
17661766
RcConfigurator = warnings._rename_objs(
1767-
'0.8', RcConfigurator=Configurator,
1767+
'0.8.0', RcConfigurator=Configurator,
17681768
)
17691769
inline_backend_fmt = warnings._rename_objs(
1770-
'0.6', inline_backend_fmt=config_inline_backend
1770+
'0.6.0', inline_backend_fmt=config_inline_backend
17711771
)

proplot/constructor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ def _modify_colormap(cmap, *, cut, left, right, reverse, shift, alpha, samples):
360360

361361

362362
@warnings._rename_kwargs(
363-
'0.8', fade='saturation', shade='luminance', to_listed='discrete'
363+
'0.8.0', fade='saturation', shade='luminance', to_listed='discrete'
364364
)
365365
def Colormap(
366366
*args, name=None, listmode='perceptual', filemode='continuous', discrete=False,
@@ -1560,5 +1560,5 @@ def Proj(
15601560

15611561
# Deprecated
15621562
Colors = warnings._rename_objs(
1563-
'0.8', Colors=get_colors
1563+
'0.8.0', Colors=get_colors
15641564
)

proplot/demos.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,8 +417,8 @@ def show_colorspaces(*, luminance=None, saturation=None, hue=None, refwidth=2):
417417
return fig, axs
418418

419419

420-
@warnings._rename_kwargs('0.8', categories='include')
421-
@warnings._rename_kwargs('0.10', rasterize='rasterized')
420+
@warnings._rename_kwargs('0.8.0', categories='include')
421+
@warnings._rename_kwargs('0.10.0', rasterize='rasterized')
422422
def _draw_bars(
423423
cmaps, *, source, unknown='User', include=None, ignore=None,
424424
length=4.0, width=0.2, N=None, rasterized=None,

proplot/figure.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,9 @@ def __repr__(self):
511511
# simply used in the warning message.
512512
@docstring._obfuscate_kwargs
513513
@docstring._snippet_manager
514-
@warnings._rename_kwargs('0.7', axpad='innerpad', autoformat='pplt.rc.autoformat = {}') # noqa: E501
514+
@warnings._rename_kwargs(
515+
'0.7.0', axpad='innerpad', autoformat='pplt.rc.autoformat = {}'
516+
)
515517
def __init__(
516518
self, *, refnum=None, ref=None, refaspect=None, aspect=None,
517519
refwidth=None, refheight=None, axwidth=None, axheight=None,
@@ -770,8 +772,8 @@ def _parse_proj(
770772
if basemap is not None:
771773
backend = ('cartopy', 'basemap')[bool(basemap)]
772774
warnings._warn_proplot(
773-
f'The {basemap!r} keyword was deprecated in version 0.10 and will be '
774-
f'removed in a future release. Please use backend={backend!r} intead.'
775+
f'The {basemap!r} keyword was deprecated in version 0.10.0 and will be '
776+
f'removed in a future release. Please use backend={backend!r} instead.'
775777
)
776778
if isinstance(proj, str):
777779
proj = proj.lower()
@@ -1463,7 +1465,9 @@ def _align_content(): # noqa: E306
14631465
gs._auto_layout_tight(renderer)
14641466
_align_content()
14651467

1466-
@warnings._rename_kwargs('0.10', mathtext_fallback='pplt.rc.mathtext_fallback = {}')
1468+
@warnings._rename_kwargs(
1469+
'0.10.0', mathtext_fallback='pplt.rc.mathtext_fallback = {}'
1470+
)
14671471
@docstring._snippet_manager
14681472
def format(
14691473
self, axs=None, *,

proplot/gridspec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1575,4 +1575,4 @@ def shape(self):
15751575
SubplotGrid._add_command(_src, _name)
15761576

15771577
# Deprecated
1578-
SubplotsContainer = warnings._rename_objs('0.8', SubplotsContainer=SubplotGrid)
1578+
SubplotsContainer = warnings._rename_objs('0.8.0', SubplotsContainer=SubplotGrid)

0 commit comments

Comments
 (0)