From a2caa86d99d53495e670db9aeebc9e0b96b32b76 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Tue, 21 Nov 2017 12:02:02 -0800 Subject: [PATCH] Deprecate Artist.onRemove, Artist.hitlist. Artist.onRemove is unused and untested; it could (should?) have been deprecated at the same time as Artist.onHilite. Artist.hitlist is only used in one example which I rewrote in a more efficient manner (no need to test every artist for containment), and can be easily replaced by a list comprehension (except for the Exception-silencing part, which is probably misguided to start with...). --- doc/api/api_changes/2017-11-23-AL.rst | 5 +++++ doc/api/artist_api.rst | 1 - doc/api/axes_api.rst | 1 - doc/api/axis_api.rst | 6 ------ examples/user_interfaces/fourier_demo_wx_sgskip.py | 4 ++-- lib/matplotlib/artist.py | 1 + lib/matplotlib/backend_bases.py | 1 + 7 files changed, 9 insertions(+), 10 deletions(-) create mode 100644 doc/api/api_changes/2017-11-23-AL.rst diff --git a/doc/api/api_changes/2017-11-23-AL.rst b/doc/api/api_changes/2017-11-23-AL.rst new file mode 100644 index 000000000000..533d4b62cd31 --- /dev/null +++ b/doc/api/api_changes/2017-11-23-AL.rst @@ -0,0 +1,5 @@ +Deprecations +```````````` + +The unused and untested ``Artist.onRemove`` and ``Artist.hitlist`` methods have +been deprecated. diff --git a/doc/api/artist_api.rst b/doc/api/artist_api.rst index de674f6fa70a..aea657e587e1 100644 --- a/doc/api/artist_api.rst +++ b/doc/api/artist_api.rst @@ -34,7 +34,6 @@ Interactive Artist.get_contains Artist.get_cursor_data Artist.get_picker - Artist.hitlist Artist.mouseover Artist.pchanged Artist.pick diff --git a/doc/api/axes_api.rst b/doc/api/axes_api.rst index d8ff77a0d9c6..f2bf9c72719c 100644 --- a/doc/api/axes_api.rst +++ b/doc/api/axes_api.rst @@ -498,7 +498,6 @@ Interactive Axes.format_xdata Axes.format_ydata - Axes.hitlist Axes.mouseover Axes.in_axes diff --git a/doc/api/axis_api.rst b/doc/api/axis_api.rst index d08e5d0614e9..4542166ca3ba 100644 --- a/doc/api/axis_api.rst +++ b/doc/api/axis_api.rst @@ -502,7 +502,6 @@ Ticks Tick.get_window_extent Tick.get_zorder Tick.have_units - Tick.hitlist Tick.is_transform_set Tick.mouseover Tick.pchanged @@ -569,7 +568,6 @@ Ticks XTick.get_window_extent XTick.get_zorder XTick.have_units - XTick.hitlist XTick.is_transform_set XTick.mouseover XTick.pchanged @@ -636,7 +634,6 @@ Ticks YTick.get_window_extent YTick.get_zorder YTick.have_units - YTick.hitlist YTick.is_transform_set YTick.mouseover YTick.pchanged @@ -713,7 +710,6 @@ Axis Axis.get_window_extent Axis.get_zorder Axis.have_units - Axis.hitlist Axis.is_transform_set Axis.mouseover Axis.pchanged @@ -780,7 +776,6 @@ Axis XAxis.get_window_extent XAxis.get_zorder XAxis.have_units - XAxis.hitlist XAxis.is_transform_set XAxis.mouseover XAxis.pchanged @@ -847,7 +842,6 @@ Axis YAxis.get_window_extent YAxis.get_zorder YAxis.have_units - YAxis.hitlist YAxis.is_transform_set YAxis.mouseover YAxis.pchanged diff --git a/examples/user_interfaces/fourier_demo_wx_sgskip.py b/examples/user_interfaces/fourier_demo_wx_sgskip.py index e5197d9a5cbf..ef1aef255712 100644 --- a/examples/user_interfaces/fourier_demo_wx_sgskip.py +++ b/examples/user_interfaces/fourier_demo_wx_sgskip.py @@ -160,9 +160,9 @@ def sizeHandler(self, *args, **kwargs): self.canvas.SetSize(self.GetSize()) def mouseDown(self, evt): - if self.lines[0] in self.figure.hitlist(evt): + if self.lines[0].contains(evt)[0]: self.state = 'frequency' - elif self.lines[1] in self.figure.hitlist(evt): + elif self.lines[1].contains(evt)[0]: self.state = 'time' else: self.state = '' diff --git a/lib/matplotlib/artist.py b/lib/matplotlib/artist.py index 2979672bb45a..c7032239726e 100644 --- a/lib/matplotlib/artist.py +++ b/lib/matplotlib/artist.py @@ -327,6 +327,7 @@ def get_transform(self): self._transform = self._transform._as_mpl_transform(self.axes) return self._transform + @cbook.deprecated("2.2") def hitlist(self, event): """ List the children of the artist which contain the mouse event *event*. diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index 97af9477e74e..88a6b3e4adec 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -1804,6 +1804,7 @@ def is_saving(self): """ return self._is_saving + @cbook.deprecated("2.2") def onRemove(self, ev): """ Mouse event processor which removes the top artist