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

Skip to content

Commit a769837

Browse files
committed
Add some more explanatory comments to deprecations.
1 parent ed2b16a commit a769837

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,15 @@ def draw(self, renderer):
400400
# add the projection matrix to the renderer
401401
self.M = self.get_proj()
402402
props3d = {
403+
# To raise a deprecation, we need to wrap the attribute in a
404+
# function, but binding that to an instance does not work, as you
405+
# would end up with an instance-specific method. Properties are
406+
# class-level attributes which *are* functions, so we do that
407+
# instead.
408+
# This dictionary comprehension creates deprecated properties for
409+
# the attributes listed below, and they are temporarily attached to
410+
# the _class_ in the `_setattr_cm` call. These can both be removed
411+
# once the deprecation expires
403412
name: cbook.deprecated('3.4', name=name,
404413
alternative=f'self.axes.{name}')(
405414
property(lambda self, _value=getattr(self, name): _value))
@@ -408,8 +417,19 @@ def draw(self, renderer):
408417

409418
with cbook._setattr_cm(type(renderer), **props3d):
410419
def do_3d_projection(artist):
420+
"""
421+
Call `do_3d_projection` on an *artist*, and warn if passing
422+
*renderer*.
423+
424+
For our Artists, never pass *renderer*. For external Artists,
425+
in lieu of more complicated signature parsing, always pass
426+
*renderer* and raise a warning.
427+
"""
428+
411429
if artist.__module__ == 'mpl_toolkits.mplot3d.art3d':
412-
# Our 3D Artists have deprecated the renderer parameter.
430+
# Our 3D Artists have deprecated the renderer parameter, so
431+
# avoid passing it to them; call this directly once the
432+
# deprecation has expired.
413433
return artist.do_3d_projection()
414434

415435
cbook.warn_deprecated(

0 commit comments

Comments
 (0)