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