From d42472aa89f09f90b9761a54d1549ce57f2b08a8 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Tue, 27 Mar 2018 16:16:47 -0700 Subject: [PATCH] Remove some APIs deprecated in mpl2.1. --- .../2018-02-26-AL-removals.rst | 4 +++ lib/matplotlib/backend_bases.py | 11 ------ lib/matplotlib/ticker.py | 34 ++++++------------- 3 files changed, 15 insertions(+), 34 deletions(-) diff --git a/doc/api/next_api_changes/2018-02-26-AL-removals.rst b/doc/api/next_api_changes/2018-02-26-AL-removals.rst index 5985f5d0c250..7eb15dcd381e 100644 --- a/doc/api/next_api_changes/2018-02-26-AL-removals.rst +++ b/doc/api/next_api_changes/2018-02-26-AL-removals.rst @@ -26,8 +26,12 @@ The following deprecated API elements have been removed: - ``_AxesBase.axesPatch``, ``_AxesBase.get_cursor_props``, ``_AxesBase.set_cursor_props``, - ``_ImageBase.iterpnames``, +- ``FigureCanvasBase.start_event_loop_default``; +- ``FigureCanvasBase.stop_event_loop_default``; - ``Figure.figurePatch``, - ``FigureCanvasBase.dynamic_update``, ``FigureCanvasBase.idle_event``, ``FigureCanvasBase.get_linestyle``, ``FigureCanvasBase.set_linestyle``, - ``FigureCanvasQTAgg.blitbox``, +- passing non-numbers to ``EngFormatter.format_eng``, - passing ``frac`` to ``PolarAxes.set_theta_grids``, +- any mention of idle events, diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index 4415b6cf8cdc..b80790578f32 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -2337,13 +2337,7 @@ def on_press(event): print('you pressed', event.button, event.xdata, event.ydata) cid = canvas.mpl_connect('button_press_event', on_press) - """ - if s == 'idle_event': - cbook.warn_deprecated(1.5, - "idle_event is only implemented for the wx backend, and will " - "be removed in matplotlib 2.1. Use the animations module " - "instead.") return self.callbacks.connect(s, func) @@ -2428,11 +2422,6 @@ def stop_event_loop(self): """ self._looping = False - start_event_loop_default = cbook.deprecated( - "2.1", name="start_event_loop_default")(start_event_loop) - stop_event_loop_default = cbook.deprecated( - "2.1", name="stop_event_loop_default")(stop_event_loop) - def key_press_handler(event, canvas, toolbar=None): """ diff --git a/lib/matplotlib/ticker.py b/lib/matplotlib/ticker.py index c151a6aca6e0..47de3e105ebe 100644 --- a/lib/matplotlib/ticker.py +++ b/lib/matplotlib/ticker.py @@ -1253,43 +1253,31 @@ def format_eng(self, num): '1.0 M' >>> format_eng("-1e-6") # for self.places = 2 - u'-1.00 \N{GREEK SMALL LETTER MU}' - - `num` may be a numeric value or a string that can be converted - to a numeric value with ``float(num)``. + '-1.00 \N{GREEK SMALL LETTER MU}' """ - if isinstance(num, six.string_types): - warnings.warn( - "Passing a string as *num* argument is deprecated since" - "Matplotlib 2.1, and is expected to be removed in 2.3.", - mplDeprecation) - - dnum = float(num) sign = 1 fmt = "g" if self.places is None else ".{:d}f".format(self.places) - if dnum < 0: + if num < 0: sign = -1 - dnum = -dnum + num = -num - if dnum != 0: - pow10 = int(math.floor(math.log10(dnum) / 3) * 3) + if num != 0: + pow10 = int(math.floor(math.log10(num) / 3) * 3) else: pow10 = 0 - # Force dnum to zero, to avoid inconsistencies like + # Force num to zero, to avoid inconsistencies like # format_eng(-0) = "0" and format_eng(0.0) = "0" # but format_eng(-0.0) = "-0.0" - dnum = 0.0 + num = 0.0 pow10 = np.clip(pow10, min(self.ENG_PREFIXES), max(self.ENG_PREFIXES)) - mant = sign * dnum / (10.0 ** pow10) - # Taking care of the cases like 999.9..., which - # may be rounded to 1000 instead of 1 k. Beware - # of the corner case of values that are beyond + mant = sign * num / (10.0 ** pow10) + # Taking care of the cases like 999.9..., which may be rounded to 1000 + # instead of 1 k. Beware of the corner case of values that are beyond # the range of SI prefixes (i.e. > 'Y'). - _fmant = float("{mant:{fmt}}".format(mant=mant, fmt=fmt)) - if _fmant >= 1000 and pow10 != max(self.ENG_PREFIXES): + if float(format(mant, fmt)) >= 1000 and pow10 < max(self.ENG_PREFIXES): mant /= 1000 pow10 += 3