|
12 | 12 |
|
13 | 13 | from collections import defaultdict
|
14 | 14 | import functools
|
| 15 | +import inspect |
15 | 16 | import itertools
|
16 | 17 | import math
|
17 | 18 | from numbers import Integral
|
@@ -412,24 +413,27 @@ def do_3d_projection(artist):
|
412 | 413 | Call `do_3d_projection` on an *artist*, and warn if passing
|
413 | 414 | *renderer*.
|
414 | 415 |
|
415 |
| - For our Artists, never pass *renderer*. For external Artists, |
416 |
| - in lieu of more complicated signature parsing, always pass |
417 |
| - *renderer* and raise a warning. |
| 416 | + Attempt to bind the empty signature first, so external Artists |
| 417 | + can avoid the deprecation warning if they support the new |
| 418 | + calling convention. |
418 | 419 | """
|
419 |
| - |
420 |
| - if artist.__module__ == 'mpl_toolkits.mplot3d.art3d': |
421 |
| - # Our 3D Artists have deprecated the renderer parameter, so |
422 |
| - # avoid passing it to them; call this directly once the |
423 |
| - # deprecation has expired. |
| 420 | + try: |
| 421 | + signature = inspect.signature(artist.do_3d_projection) |
| 422 | + signature.bind() |
| 423 | + # ValueError if `inspect.signature` cannot provide a signature |
| 424 | + # and TypeError if the binding fails or the object does not |
| 425 | + # appear to be callable - the next call will then re-raise. |
| 426 | + except (ValueError, TypeError): |
| 427 | + _api.warn_deprecated( |
| 428 | + "3.4", |
| 429 | + message="The 'renderer' parameter of " |
| 430 | + "do_3d_projection() was deprecated in Matplotlib " |
| 431 | + "%(since)s and will be removed %(removal)s.") |
| 432 | + return artist.do_3d_projection(renderer) |
| 433 | + else: |
| 434 | + # Call this directly once the deprecation period expires. |
424 | 435 | return artist.do_3d_projection()
|
425 | 436 |
|
426 |
| - _api.warn_deprecated( |
427 |
| - "3.4", |
428 |
| - message="The 'renderer' parameter of " |
429 |
| - "do_3d_projection() was deprecated in Matplotlib " |
430 |
| - "%(since)s and will be removed %(removal)s.") |
431 |
| - return artist.do_3d_projection(renderer) |
432 |
| - |
433 | 437 | collections_and_patches = (
|
434 | 438 | artist for artist in self._children
|
435 | 439 | if isinstance(artist, (mcoll.Collection, mpatches.Patch))
|
|
0 commit comments