Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c51ae6d

Browse filesBrowse files
committed
Remove artist-specific deprecations from 3.3.
1 parent b2667e8 commit c51ae6d
Copy full SHA for c51ae6d

File tree

Expand file treeCollapse file tree

7 files changed

+31
-100
lines changed
Filter options
Expand file treeCollapse file tree

7 files changed

+31
-100
lines changed

‎doc/api/artist_api.rst

Copy file name to clipboardExpand all lines: doc/api/artist_api.rst
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ Interactive
3636
Artist.format_cursor_data
3737
Artist.mouseover
3838
Artist.contains
39-
Artist.set_contains
40-
Artist.get_contains
4139
Artist.pick
4240
Artist.pickable
4341
Artist.set_picker

‎doc/api/next_api_changes/removals/20465-ES.rst

Copy file name to clipboardExpand all lines: doc/api/next_api_changes/removals/20465-ES.rst
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,20 @@ to force the use of avconv by using the FFmpeg-based writers with
2828
* *clear_temp* parameter and attribute of `.FileMovieWriter`; files placed in a
2929
temporary directory (using ``frame_prefix=None``, the default) will be
3030
cleared; files placed elsewhere will not.
31+
32+
Artist-specific removals
33+
~~~~~~~~~~~~~~~~~~~~~~~~
34+
* Setting a custom method overriding `.Artist.contains` using
35+
``Artist.set_contains`` has been removed, as has ``Artist.get_contains``.
36+
There is no replacement, but you may still customize pick events using
37+
`.Artist.set_picker`.
38+
* Passing the dash offset as ``None`` is no longer accepted, as this was never
39+
universally implemented, e.g. for vector output. Set the offset to 0 instead.
40+
* The parameter *props* of `.Shadow` has been removed. Use keyword arguments
41+
instead.
42+
* Arbitrary keyword arguments to ``StreamplotSet`` have no effect and have been
43+
removed.
44+
* ``NonUniformImage.is_grayscale`` and ``PcolorImage.is_grayscale`` attributes
45+
have been removed, for consistency with ``AxesImage.is_grayscale``. (Note
46+
that previously, these attributes were only available *after rendering the
47+
image*).

‎lib/matplotlib/artist.py

Copy file name to clipboardExpand all lines: lib/matplotlib/artist.py
+2-45Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ def __init__(self):
109109
self._clipon = True
110110
self._label = ''
111111
self._picker = None
112-
self._contains = None
113112
self._rasterized = False
114113
self._agg_filter = None
115114
# Normally, artist classes need to be queried for mouseover info if and
@@ -401,10 +400,9 @@ def _default_contains(self, mouseevent, figure=None):
401400
"""
402401
Base impl. for checking whether a mouseevent happened in an artist.
403402
404-
1. If the artist defines a custom checker, use it (deprecated).
405-
2. If the artist figure is known and the event did not occur in that
403+
1. If the artist figure is known and the event did not occur in that
406404
figure (by checking its ``canvas`` attribute), reject it.
407-
3. Otherwise, return `None, {}`, indicating that the subclass'
405+
2. Otherwise, return `None, {}`, indicating that the subclass'
408406
implementation should be used.
409407
410408
Subclasses should start their definition of `contains` as follows:
@@ -417,8 +415,6 @@ def _default_contains(self, mouseevent, figure=None):
417415
The *figure* kwarg is provided for the implementation of
418416
`.Figure.contains`.
419417
"""
420-
if callable(self._contains):
421-
return self._contains(self, mouseevent)
422418
if figure is not None and mouseevent.canvas is not figure.canvas:
423419
return False, {}
424420
return None, {}
@@ -446,45 +442,6 @@ def contains(self, mouseevent):
446442
_log.warning("%r needs 'contains' method", self.__class__.__name__)
447443
return False, {}
448444

449-
@_api.deprecated("3.3", alternative="set_picker")
450-
def set_contains(self, picker):
451-
"""
452-
Define a custom contains test for the artist.
453-
454-
The provided callable replaces the default `.contains` method
455-
of the artist.
456-
457-
Parameters
458-
----------
459-
picker : callable
460-
A custom picker function to evaluate if an event is within the
461-
artist. The function must have the signature::
462-
463-
def contains(artist: Artist, event: MouseEvent) -> bool, dict
464-
465-
that returns:
466-
467-
- a bool indicating if the event is within the artist
468-
- a dict of additional information. The dict should at least
469-
return the same information as the default ``contains()``
470-
implementation of the respective artist, but may provide
471-
additional information.
472-
"""
473-
if not callable(picker):
474-
raise TypeError("picker is not a callable")
475-
self._contains = picker
476-
477-
@_api.deprecated("3.3", alternative="get_picker")
478-
def get_contains(self):
479-
"""
480-
Return the custom contains function of the artist if set, or *None*.
481-
482-
See Also
483-
--------
484-
set_contains
485-
"""
486-
return self._contains
487-
488445
def pickable(self):
489446
"""
490447
Return whether the artist is pickable.

‎lib/matplotlib/image.py

Copy file name to clipboardExpand all lines: lib/matplotlib/image.py
+3-17Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,8 +1015,6 @@ def _check_unsampled_image(self):
10151015
"""Return False. Do not use unsampled image."""
10161016
return False
10171017

1018-
is_grayscale = _api.deprecate_privatize_attribute("3.3")
1019-
10201018
def make_image(self, renderer, magnification=1.0, unsampled=False):
10211019
# docstring inherited
10221020
if self._A is None:
@@ -1027,11 +1025,9 @@ def make_image(self, renderer, magnification=1.0, unsampled=False):
10271025
if A.ndim == 2:
10281026
if A.dtype != np.uint8:
10291027
A = self.to_rgba(A, bytes=True)
1030-
self._is_grayscale = self.cmap.is_gray()
10311028
else:
10321029
A = np.repeat(A[:, :, np.newaxis], 4, 2)
10331030
A[:, :, 3] = 255
1034-
self._is_grayscale = True
10351031
else:
10361032
if A.dtype != np.uint8:
10371033
A = (255*A).astype(np.uint8)
@@ -1040,7 +1036,6 @@ def make_image(self, renderer, magnification=1.0, unsampled=False):
10401036
B[:, :, 0:3] = A
10411037
B[:, :, 3] = 255
10421038
A = B
1043-
self._is_grayscale = False
10441039
vl = self.axes.viewLim
10451040
l, b, r, t = self.axes.bbox.extents
10461041
width = int(((round(r) + 0.5) - (round(l) - 0.5)) * magnification)
@@ -1203,8 +1198,6 @@ def __init__(self, ax,
12031198
if A is not None:
12041199
self.set_data(x, y, A)
12051200

1206-
is_grayscale = _api.deprecate_privatize_attribute("3.3")
1207-
12081201
def make_image(self, renderer, magnification=1.0, unsampled=False):
12091202
# docstring inherited
12101203
if self._A is None:
@@ -1215,8 +1208,6 @@ def make_image(self, renderer, magnification=1.0, unsampled=False):
12151208
if self._rgbacache is None:
12161209
A = self.to_rgba(self._A, bytes=True)
12171210
self._rgbacache = np.pad(A, [(1, 1), (1, 1), (0, 0)], "constant")
1218-
if self._A.ndim == 2:
1219-
self._is_grayscale = self.cmap.is_gray()
12201211
padded_A = self._rgbacache
12211212
bg = mcolors.to_rgba(self.axes.patch.get_facecolor(), 0)
12221213
bg = (np.array(bg) * 255).astype(np.uint8)
@@ -1277,15 +1268,10 @@ def set_data(self, x, y, A):
12771268
(A.shape[:2], (y.size - 1, x.size - 1)))
12781269
if A.ndim not in [2, 3]:
12791270
raise ValueError("A must be 2D or 3D")
1280-
if A.ndim == 3 and A.shape[2] == 1:
1281-
A = A.squeeze(axis=-1)
1282-
self._is_grayscale = False
12831271
if A.ndim == 3:
1284-
if A.shape[2] in [3, 4]:
1285-
if ((A[:, :, 0] == A[:, :, 1]).all() and
1286-
(A[:, :, 0] == A[:, :, 2]).all()):
1287-
self._is_grayscale = True
1288-
else:
1272+
if A.shape[2] == 1:
1273+
A = A.squeeze(axis=-1)
1274+
elif A.shape[2] not in [3, 4]:
12891275
raise ValueError("3D arrays must have RGB or RGBA as last dim")
12901276

12911277
# For efficient cursor readout, ensure x and y are increasing.

‎lib/matplotlib/lines.py

Copy file name to clipboardExpand all lines: lib/matplotlib/lines.py
+2-6Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,9 @@ def _get_dash_pattern(style):
4545
elif isinstance(style, tuple):
4646
offset, dashes = style
4747
if offset is None:
48-
_api.warn_deprecated(
49-
"3.3", message="Passing the dash offset as None is deprecated "
50-
"since %(since)s and support for it will be removed "
51-
"%(removal)s; pass it as zero instead.")
52-
offset = 0
48+
raise ValueError(f'Unrecognized linestyle: {style!r}')
5349
else:
54-
raise ValueError('Unrecognized linestyle: %s' % str(style))
50+
raise ValueError(f'Unrecognized linestyle: {style!r}')
5551

5652
# normalize offset to be positive and shorter than the dash cycle
5753
if dashes is not None:

‎lib/matplotlib/patches.py

Copy file name to clipboardExpand all lines: lib/matplotlib/patches.py
+6-23Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -636,9 +636,8 @@ class Shadow(Patch):
636636
def __str__(self):
637637
return "Shadow(%s)" % (str(self.patch))
638638

639-
@_api.delete_parameter("3.3", "props")
640639
@docstring.dedent_interpd
641-
def __init__(self, patch, ox, oy, props=None, **kwargs):
640+
def __init__(self, patch, ox, oy, **kwargs):
642641
"""
643642
Create a shadow of the given *patch*.
644643
@@ -652,38 +651,22 @@ def __init__(self, patch, ox, oy, props=None, **kwargs):
652651
ox, oy : float
653652
The shift of the shadow in data coordinates, scaled by a factor
654653
of dpi/72.
655-
props : dict
656-
*deprecated (use kwargs instead)* Properties of the shadow patch.
657654
**kwargs
658655
Properties of the shadow patch. Supported keys are:
659656
660657
%(Patch:kwdoc)s
661658
"""
662659
super().__init__()
663660
self.patch = patch
664-
# Note: when removing props, we can directly pass kwargs to _update()
665-
# and remove self._props
666-
if props is None:
667-
color = .3 * np.asarray(colors.to_rgb(self.patch.get_facecolor()))
668-
props = {
669-
'facecolor': color,
670-
'edgecolor': color,
671-
'alpha': 0.5,
672-
}
673-
self._props = {**props, **kwargs}
674661
self._ox, self._oy = ox, oy
675662
self._shadow_transform = transforms.Affine2D()
676-
self._update()
677663

678-
props = _api.deprecate_privatize_attribute("3.3")
679-
680-
def _update(self):
681664
self.update_from(self.patch)
682-
683-
# Place the shadow patch directly behind the inherited patch.
684-
self.set_zorder(np.nextafter(self.patch.zorder, -np.inf))
685-
686-
self.update(self._props)
665+
color = .3 * np.asarray(colors.to_rgb(self.patch.get_facecolor()))
666+
self.update({'facecolor': color, 'edgecolor': color, 'alpha': 0.5,
667+
# Place shadow patch directly behind the inherited patch.
668+
'zorder': np.nextafter(self.patch.zorder, -np.inf),
669+
**kwargs})
687670

688671
def _update_transform(self, renderer):
689672
ox = renderer.points_to_pixels(self._ox)

‎lib/matplotlib/streamplot.py

Copy file name to clipboardExpand all lines: lib/matplotlib/streamplot.py
+1-7Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,7 @@ def streamplot(axes, x, y, u, v, density=1, linewidth=None, color=None,
236236

237237
class StreamplotSet:
238238

239-
def __init__(self, lines, arrows, **kwargs):
240-
if kwargs:
241-
_api.warn_deprecated(
242-
"3.3",
243-
message="Passing arbitrary keyword arguments to StreamplotSet "
244-
"is deprecated since %(since) and will become an "
245-
"error %(removal)s.")
239+
def __init__(self, lines, arrows):
246240
self.lines = lines
247241
self.arrows = arrows
248242

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.