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

Skip to content

Commit ebac289

Browse files
committed
Add some more explanatory comments to deprecations.
1 parent 1afbf3b commit ebac289

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,14 @@ def draw(self, renderer):
435435
# add the projection matrix to the renderer
436436
self.M = self.get_proj()
437437
props3d = {
438+
# To raise a deprecation, we need to wrap the attribute in a
439+
# function, but binding that to an instance does not work, as you
440+
# would end up with an instance-specific method. Properties are
441+
# class-level attributes which *are* functions, so we do that
442+
# instead.
443+
# This creates deprecated properties for the attributes listed
444+
# below, and they are temporarily attached to the _class_ in the
445+
# `_setattr_cm` call.
438446
name: cbook.deprecated('3.4', name=name,
439447
alternative=f'self.axes.{name}')(
440448
property(lambda self, _value=getattr(self, name): _value))
@@ -443,8 +451,18 @@ def draw(self, renderer):
443451

444452
with cbook._setattr_cm(type(renderer), **props3d):
445453
def do_3d_projection(artist):
454+
"""
455+
Call `do_3d_projection` on an *artist*, and warn if passing
456+
*renderer*.
457+
458+
For our Artists, never pass *renderer*. For external Artists,
459+
in lieu of more complicated signature parsing, always pass
460+
*renderer* and raise a warning.
461+
"""
462+
446463
if artist.__module__ == 'mpl_toolkits.mplot3d.art3d':
447-
# Our 3D Artists have deprecated the renderer parameter.
464+
# Our 3D Artists have deprecated the renderer parameter, so
465+
# avoid passing it to them.
448466
return artist.do_3d_projection()
449467

450468
cbook.warn_deprecated(

0 commit comments

Comments
 (0)