8000 Reduce do_3d_projection deprecation warnings in external artists by jakelishman · Pull Request #21741 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
Merged
Changes from 1 commit
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
34 changes: 19 additions & 15 deletions lib/mpl_toolkits/mplot3d/axes3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from collections import defaultdict
import functools
import inspect
import itertools
import math
from numbers import Integral
Expand Down Expand Up @@ -412,24 +413,27 @@ def do_3d_projection(artist):
Call `do_3d_projection` on an *artist*, and warn if passing
*renderer*.

For our Artists, never pass *renderer*. For external Artists,
in lieu of more complicated signature parsing, always pass
*renderer* and raise a warning.
Attempt to bind the empty signature first, so external Artists
can avoid the deprecation warning if they support the new
calling convention.
"""

if artist.__module__ == 'mpl_toolkits.mplot3d.art3d':
# Our 3D Artists have deprecated the renderer parameter, so
# avoid passing it to them; call this directly once the
# deprecation has expired.
try:
signature = inspect.signature(artist.do_3d_projection)
signature.bind()
# ValueError if `inspect.signature` cannot provide a signature
# and TypeError if the binding fails or the object does not
# appear to be callable - the next call will then re-raise.
except (ValueError, TypeError):
_api.warn_deprecated(
"3.4",
message="The 'renderer' parameter of "
"do_3d_projection() was deprecated in Matplotlib "
"%(since)s and will be removed %(removal)s.")
return artist.do_3d_projection(renderer)
else:
# Call this directly once the deprecation period expires.
return artist.do_3d_projection()

_api.warn_deprecated(
"3.4",
message="The 'renderer' parameter of "
"do_3d_projection() was deprecated in Matplotlib "
"%(since)s and will be removed %(removal)s.")
return artist.do_3d_projection(renderer)

collections_and_patches = (
artist for artist in self._children
if isinstance(artist, (mcoll.Collection, mpatches.Patch))
Expand Down
0