Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit227c171

Browse files
committed
Deprecate cbook.warn_deprecated and move internal calls to _api.warn_deprecated
1 parent0520035 commit227c171

37 files changed

+115
-102
lines changed
Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1-
``matplotlib.cbook.deprecation`` is deprecated
2-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3-
The module is considered internal and will be removed from the public API.
1+
Deprecation-related functionality is considered internal
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
The module ``matplotlib.cbook.deprecation`` is considered internal and will be
4+
removed from the public API. This also holds for deprecation-related re-imports
5+
in ``matplotlib.cbook``, i.e. ``matplotlib.cbook.deprecated()``,
6+
``matplotlib.cbook.warn_deprecated()``,
7+
``matplotlib.cbook.MatplotlibDeprecationWarning`` and
8+
``matplotlib.cbook.mplDeprecation``.
9+
10+
If needed, external users may import ``MatplotlibDeprecationWarning`` directly
11+
from the ``matplotlib`` namespace. ``mplDeprecation`` is only an alias of
12+
``MatplotlibDeprecationWarning`` and should not be used anymore.

‎lib/matplotlib/__init__.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ def get_cachedir():
472472
defget_data_path(*,_from_rc=None):
473473
"""Return the path to Matplotlib data."""
474474
if_from_rcisnotNone:
475-
cbook.warn_deprecated(
475+
_api.warn_deprecated(
476476
"3.2",
477477
message=("Setting the datapath via matplotlibrc is deprecated "
478478
"%(since)s and will be removed %(removal)s."),
@@ -495,7 +495,7 @@ def _get_data_path():
495495
ifpath.is_dir():
496496
returnstr(path)
497497

498-
cbook.warn_deprecated(
498+
_api.warn_deprecated(
499499
"3.2",message="Matplotlib installs where the data is not in the "
500500
"mpl-data subdirectory of the package are deprecated since %(since)s "
501501
"and support for them will be removed %(removal)s.")
@@ -617,17 +617,16 @@ def __setitem__(self, key, val):
617617
try:
618618
ifkeyin_deprecated_map:
619619
version,alt_key,alt_val,inverse_alt=_deprecated_map[key]
620-
cbook.warn_deprecated(
620+
_api.warn_deprecated(
621621
version,name=key,obj_type="rcparam",alternative=alt_key)
622622
key=alt_key
623623
val=alt_val(val)
624624
elifkeyin_deprecated_remain_as_noneandvalisnotNone:
625625
version,=_deprecated_remain_as_none[key]
626-
cbook.warn_deprecated(
627-
version,name=key,obj_type="rcparam")
626+
_api.warn_deprecated(version,name=key,obj_type="rcparam")
628627
elifkeyin_deprecated_ignore_map:
629628
version,alt_key=_deprecated_ignore_map[key]
630-
cbook.warn_deprecated(
629+
_api.warn_deprecated(
631630
version,name=key,obj_type="rcparam",alternative=alt_key)
632631
return
633632
elifkey=='backend':
@@ -647,13 +646,13 @@ def __setitem__(self, key, val):
647646
def__getitem__(self,key):
648647
ifkeyin_deprecated_map:
649648
version,alt_key,alt_val,inverse_alt=_deprecated_map[key]
650-
cbook.warn_deprecated(
649+
_api.warn_deprecated(
651650
version,name=key,obj_type="rcparam",alternative=alt_key)
652651
returninverse_alt(dict.__getitem__(self,alt_key))
653652

654653
elifkeyin_deprecated_ignore_map:
655654
version,alt_key=_deprecated_ignore_map[key]
656-
cbook.warn_deprecated(
655+
_api.warn_deprecated(
657656
version,name=key,obj_type="rcparam",alternative=alt_key)
658657
returndict.__getitem__(self,alt_key)ifalt_keyelseNone
659658

@@ -811,7 +810,7 @@ def _rc_params_in_file(fname, transform=lambda x: x, fail_on_error=False):
811810
fname,line_no,line.rstrip('\n'),msg)
812811
elifkeyin_deprecated_ignore_map:
813812
version,alt_key=_deprecated_ignore_map[key]
814-
cbook.warn_deprecated(
813+
_api.warn_deprecated(
815814
version,name=key,alternative=alt_key,obj_type='rcparam',
816815
addendum="Please update your matplotlibrc.")
817816
else:

‎lib/matplotlib/animation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1719,7 +1719,7 @@ def gen():
17191719
exceptStopIteration:
17201720
pass
17211721
else:
1722-
cbook.warn_deprecated(
1722+
_api.warn_deprecated(
17231723
"2.2",message="FuncAnimation.save has truncated "
17241724
"your animation to 100 frames. In the future, no "
17251725
"such truncation will occur; please pass "

‎lib/matplotlib/artist.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,7 @@ def update(self, props):
10361036
withcbook._setattr_cm(self,eventson=False):
10371037
fork,vinprops.items():
10381038
ifk!=k.lower():
1039-
cbook.warn_deprecated(
1039+
_api.warn_deprecated(
10401040
"3.3",message="Case-insensitive properties were "
10411041
"deprecated in %(since)s and support will be removed "
10421042
"%(removal)s")
@@ -1156,7 +1156,7 @@ def set(self, **kwargs):
11561156
i_other=keys.index(other)
11571157
ifi_other<i_color:
11581158
move_color_to_start=True
1159-
cbook.warn_deprecated(
1159+
_api.warn_deprecated(
11601160
"3.3",message=f"You have passed the{other!r} kwarg "
11611161
"before the 'color' kwarg. Artist.set() currently "
11621162
"reorders the properties to apply 'color' first, but "

‎lib/matplotlib/axes/_axes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3032,7 +3032,7 @@ def pie(self, x, explode=None, labels=None, colors=None,
30323032

30333033
ifnormalizeisNone:
30343034
ifsx<1:
3035-
cbook.warn_deprecated(
3035+
_api.warn_deprecated(
30363036
"3.3",message="normalize=None does not normalize "
30373037
"if the sum is less than 1 but this behavior "
30383038
"is deprecated since %(since)s until %(removal)s. "
@@ -3062,15 +3062,15 @@ def get_next_color():
30623062
returnnext(color_cycle)
30633063

30643064
ifradiusisNone:
3065-
cbook.warn_deprecated(
3065+
_api.warn_deprecated(
30663066
"3.3",message="Support for passing a radius of None to mean "
30673067
"1 is deprecated since %(since)s and will be removed "
30683068
"%(removal)s.")
30693069
radius=1
30703070

30713071
# Starting theta1 is the start fraction of the circle
30723072
ifstartangleisNone:
3073-
cbook.warn_deprecated(
3073+
_api.warn_deprecated(
30743074
"3.3",message="Support for passing a startangle of None to "
30753075
"mean 0 is deprecated since %(since)s and will be removed "
30763076
"%(removal)s.")
@@ -5634,7 +5634,7 @@ def _pcolorargs(self, funcname, *args, shading='flat', **kwargs):
56345634
' X (%d) and/or Y (%d); see help(%s)'% (
56355635
C.shape,Nx,Ny,funcname))
56365636
if (ncols==Nxornrows==Ny):
5637-
cbook.warn_deprecated(
5637+
_api.warn_deprecated(
56385638
"3.3",message="shading='flat' when X and Y have the same "
56395639
"dimensions as C is deprecated since %(since)s. Either "
56405640
"specify the corners of the quadrilaterals with X and Y, "

‎lib/matplotlib/axes/_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2772,7 +2772,7 @@ def _update_title_position(self, renderer):
27722772
defdraw(self,renderer=None,inframe=False):
27732773
# docstring inherited
27742774
ifrendererisNone:
2775-
cbook.warn_deprecated(
2775+
_api.warn_deprecated(
27762776
"3.3",message="Support for not passing the 'renderer' "
27772777
"parameter to Axes.draw() is deprecated since %(since)s and "
27782778
"will be removed %(removal)s. Use axes.draw_artist(axes) "

‎lib/matplotlib/axes/_subplots.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
importfunctools
22
importuuid
33

4-
frommatplotlibimport_api,cbook,docstring
4+
frommatplotlibimport_api,docstring
55
importmatplotlib.artistasmartist
66
frommatplotlib.axes._axesimportAxes
77
frommatplotlib.gridspecimportGridSpec,SubplotSpec
@@ -180,7 +180,7 @@ def subplot_class_factory(axes_class=None):
180180
not have to be created for every type of Axes.
181181
"""
182182
ifaxes_classisNone:
183-
cbook.warn_deprecated(
183+
_api.warn_deprecated(
184184
"3.3",message="Support for passing None to subplot_class_factory "
185185
"is deprecated since %(since)s; explicitly pass the default Axes "
186186
"class instead. This will become an error %(removal)s.")

‎lib/matplotlib/backend_bases.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ def _iter_collection(self, gc, master_transform, all_transforms,
416416
Nurls=len(urls)
417417

418418
ifoffset_position=="data":
419-
cbook.warn_deprecated(
419+
_api.warn_deprecated(
420420
"3.3",message="Support for offset_position='data' is "
421421
"deprecated since %(since)s and will be removed %(removal)s.")
422422

@@ -1191,7 +1191,7 @@ def remove_callback(self, func, *args, **kwargs):
11911191
pass it to `add_callback` as a `functools.partial` object.
11921192
"""
11931193
ifargsorkwargs:
1194-
cbook.warn_deprecated(
1194+
_api.warn_deprecated(
11951195
"3.1",message="In a future version, Timer.remove_callback "
11961196
"will not take *args, **kwargs anymore, but remove all "
11971197
"callbacks where the callable matches; to keep a specific "
@@ -1652,7 +1652,7 @@ def wrapper(*args, **kwargs):
16521652
forarginlist(kwargs):
16531653
ifarginaccepted_kwargs:
16541654
continue
1655-
cbook.warn_deprecated(
1655+
_api.warn_deprecated(
16561656
'3.3',name=name,
16571657
message='%(name)s() got unexpected keyword argument "'
16581658
+arg+'" which is no longer supported as of '
@@ -1967,7 +1967,7 @@ def enter_notify_event(self, guiEvent=None, xy=None):
19671967
else:
19681968
x=None
19691969
y=None
1970-
cbook.warn_deprecated(
1970+
_api.warn_deprecated(
19711971
'3.0',removal='3.5',name='enter_notify_event',
19721972
message='Since %(since)s, %(name)s expects a location but '
19731973
'your backend did not pass one. This will become an error '
@@ -2607,7 +2607,7 @@ def _get_uniform_gridstate(ticks):
26072607
foraincanvas.figure.get_axes():
26082608
if (event.xisnotNoneandevent.yisnotNone
26092609
anda.in_axes(event)):# FIXME: Why only these?
2610-
cbook.warn_deprecated(
2610+
_api.warn_deprecated(
26112611
"3.3",message="Toggling axes navigation from the "
26122612
"keyboard is deprecated since %(since)s and will be "
26132613
"removed %(removal)s.")
@@ -2620,7 +2620,7 @@ def _get_uniform_gridstate(ticks):
26202620
fori,ainenumerate(canvas.figure.get_axes()):
26212621
if (event.xisnotNoneandevent.yisnotNone
26222622
anda.in_axes(event)):# FIXME: Why only these?
2623-
cbook.warn_deprecated(
2623+
_api.warn_deprecated(
26242624
"3.3",message="Toggling axes navigation from the "
26252625
"keyboard is deprecated since %(since)s and will be "
26262626
"removed %(removal)s.")

‎lib/matplotlib/backend_managers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def update_keymap(self, name, key, *args):
199199
self._remove_keys(name)
200200
forkeyin [key,*args]:
201201
ifisinstance(key,str)andvalidate_stringlist(key)!= [key]:
202-
cbook.warn_deprecated(
202+
_api.warn_deprecated(
203203
"3.3",message="Passing a list of keys as a single "
204204
"comma-separated string is deprecated since %(since)s and "
205205
"support will be removed %(removal)s; pass keys as a list "

‎lib/matplotlib/backends/backend_agg.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def draw_path_collection(self, gc, master_transform, paths, all_transforms,
168168
linewidths,linestyles,antialiaseds,urls,
169169
offset_position):
170170
ifoffset_position=="data":
171-
cbook.warn_deprecated(
171+
_api.warn_deprecated(
172172
"3.3",message="Support for offset_position='data' is "
173173
"deprecated since %(since)s and will be removed %(removal)s.")
174174
returnself._renderer.draw_path_collection(
@@ -219,7 +219,7 @@ def get_text_width_height_descent(self, s, prop, ismath):
219219

220220
ifismathin ["TeX","TeX!"]:
221221
ifismath=="TeX!":
222-
cbook._warn_deprecated(
222+
_api.warn_deprecated(
223223
"3.3",message="Support for ismath='TeX!' is deprecated "
224224
"since %(since)s and will be removed %(removal)s; use "
225225
"ismath='TeX' instead.")
@@ -573,7 +573,7 @@ def print_jpg(self, filename_or_obj, *args, pil_kwargs=None, **kwargs):
573573
quality=pil_kwargs["quality"]= \
574574
dict.__getitem__(mpl.rcParams,"savefig.jpeg_quality")
575575
ifqualitynotin [0,75,95]:# default qualities.
576-
cbook.warn_deprecated(
576+
_api.warn_deprecated(
577577
"3.3",name="savefig.jpeg_quality",obj_type="rcParam",
578578
addendum="Set the quality using "
579579
"`pil_kwargs={'quality': ...}`; the future default "

‎lib/matplotlib/backends/backend_pgf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,7 @@ def __init__(self, filename, *, keep_empty=True, metadata=None):
969969
'moddate':'ModDate',
970970
}.get(key.lower(),key.lower().title())
971971
ifcanonical!=key:
972-
cbook.warn_deprecated(
972+
_api.warn_deprecated(
973973
'3.3',message='Support for setting PDF metadata keys '
974974
'case-insensitively is deprecated since %(since)s and '
975975
'will be removed %(removal)s; '

‎lib/matplotlib/backends/backend_qt4.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
from ..importcbook
1+
from ..import_api
22
from .backend_qt5import (
33
backend_version,SPECIAL_KEYS,
44
SUPER,ALT,CTRL,SHIFT,MODIFIER_KEYS,# These are deprecated.
55
cursord,_create_qApp,_BackendQT5,TimerQT,MainWindow,FigureCanvasQT,
66
FigureManagerQT,NavigationToolbar2QT,SubplotToolQt,exception_handler)
77

88

9-
cbook.warn_deprecated("3.3",name=__name__,obj_type="backend")
9+
_api.warn_deprecated("3.3",name=__name__,obj_type="backend")
1010

1111

1212
@_BackendQT5.export

‎lib/matplotlib/backends/backend_qt4agg.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
Render to qt from agg
33
"""
44

5-
from ..importcbook
5+
from ..import_api
66
from .backend_qt5aggimport (
77
_BackendQT5Agg,FigureCanvasQTAgg,FigureManagerQT,NavigationToolbar2QT)
88

99

10-
cbook.warn_deprecated("3.3",name=__name__,obj_type="backend")
10+
_api.warn_deprecated("3.3",name=__name__,obj_type="backend")
1111

1212

1313
@_BackendQT5Agg.export

‎lib/matplotlib/backends/backend_qt4cairo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
from ..importcbook
1+
from ..import_api
22
from .backend_qt5cairoimport_BackendQT5Cairo,FigureCanvasQTCairo
33

44

5-
cbook.warn_deprecated("3.3",name=__name__,obj_type="backend")
5+
_api.warn_deprecated("3.3",name=__name__,obj_type="backend")
66

77

88
@_BackendQT5Cairo.export

‎lib/matplotlib/backends/backend_wx.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ class RendererWx(RendererBase):
142142

143143
def__init__(self,bitmap,dpi):
144144
"""Initialise a wxWindows renderer instance."""
145-
cbook.warn_deprecated(
145+
_api.warn_deprecated(
146146
"2.0",name="wx",obj_type="backend",removal="the future",
147147
alternative="wxagg",addendum="See the Matplotlib usage FAQ for "
148148
"more info on backends.")

‎lib/matplotlib/backends/qt_compat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def is_pyqt5():
185185
QT_RC_MAJOR_VERSION=int(QtCore.qVersion().split(".")[0])
186186

187187
ifQT_RC_MAJOR_VERSION==4:
188-
mpl.cbook.warn_deprecated("3.3",name="support for Qt4")
188+
_api.warn_deprecated("3.3",name="support for Qt4")
189189

190190

191191
def_devicePixelRatioF(obj):
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
frommatplotlibimportcbook
1+
frommatplotlibimport_api
22
from ._formsubplottoolimportUiSubplotTool
33

44

5-
cbook.warn_deprecated(
5+
_api.warn_deprecated(
66
"3.3",obj_type="module",name=__name__,
77
alternative="matplotlib.backends.backend_qt5.SubplotToolQt")
88
__all__= ["UiSubplotTool"]

‎lib/matplotlib/cbook/__init__.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,19 @@
3030
importmatplotlib
3131
frommatplotlibimport_api,_c_internal_utils
3232
frommatplotlib._api.deprecationimport (
33-
warn_deprecated,MatplotlibDeprecationWarning,mplDeprecation)
33+
MatplotlibDeprecationWarning,mplDeprecation)
3434

3535

3636
@_api.deprecated("3.4")
3737
defdeprecated(*args,**kwargs):
3838
return_api.deprecated(*args,**kwargs)
3939

4040

41+
@_api.deprecated("3.4")
42+
defwarn_deprecated(*args,**kwargs):
43+
_api.warn_deprecated(*args,**kwargs)
44+
45+
4146
def_get_running_interactive_framework():
4247
"""
4348
Return the interactive framework whose event loop is currently running, if
@@ -427,9 +432,9 @@ def to_filehandle(fname, flag='r', return_opened=False, encoding=None):
427432
ifisinstance(fname,os.PathLike):
428433
fname=os.fspath(fname)
429434
if"U"inflag:
430-
warn_deprecated("3.3",message="Passing a flag containing 'U' to "
431-
"to_filehandle() is deprecated since %(since)s and "
432-
"will be removed %(removal)s.")
435+
_api.warn_deprecated(
436+
"3.3",message="Passing a flag containing 'U' toto_filehandle() "
437+
"is deprecated since %(since)s andwill be removed %(removal)s.")
433438
flag=flag.replace("U","")
434439
ifisinstance(fname,str):
435440
iffname.endswith('.gz'):
@@ -491,7 +496,7 @@ def get_sample_data(fname, asfileobj=True, *, np_load=False):
491496
ifnp_load:
492497
returnnp.load(path)
493498
else:
494-
warn_deprecated(
499+
_api.warn_deprecated(
495500
"3.3",message="In a future release, get_sample_data "
496501
"will automatically load numpy arrays. Set np_load to "
497502
"True to get the array and suppress this warning. Set "

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp