diff --git a/doc/api/axes_api.rst b/doc/api/axes_api.rst index 0e321bf7d6a0..c7a363b08a1e 100644 --- a/doc/api/axes_api.rst +++ b/doc/api/axes_api.rst @@ -509,8 +509,6 @@ Interactive Axes.contains_point Axes.get_cursor_data - Axes.get_cursor_props - Axes.set_cursor_props Children ======== 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 new file mode 100644 index 000000000000..5985f5d0c250 --- /dev/null +++ b/doc/api/next_api_changes/2018-02-26-AL-removals.rst @@ -0,0 +1,33 @@ +Removal of deprecated APIs +`````````````````````````` +The following deprecated API elements have been removed: + +- ``matplotlib.checkdep_tex``, ``matplotlib.checkdep_xmllint``, +- ``backend_bases.IdleEvent``, +- ``cbook.converter``, ``cbook.tostr``, ``cbook.todatetime``, ``cbook.todate``, + ``cbook.tofloat``, ``cbook.toint``, ``cbook.unique``, + ``cbook.is_string_like``, ``cbook.is_sequence_of_strings``, + ``cbook.is_scalar``, ``cbook.soundex``, ``cbook.dict_delall``, + ``cbook.get_split_ind``, ``cbook.wrap``, ``cbook.get_recursive_filelist``, + ``cbook.pieces``, ``cbook.exception_to_str``, ``cbook.allequal``, + ``cbook.alltrue``, ``cbook.onetrue``, ``cbook.allpairs``, ``cbook.finddir``, + ``cbook.reverse_dict``, ``cbook.restrict_dict``, ``cbook.issubclass_safe``, + ``cbook.recursive_remove``, ``cbook.unmasked_index_ranges``, + ``cbook.Null``, ``cbook.RingBuffer``, ``cbook.Sorter``, ``cbook.Xlator``, +- ``font_manager.weight_as_number``, ``font_manager.ttfdict_to_fnames``, +- ``pyplot.colors``, +- ``rcsetup.validate_negative_linestyle``, + ``rcsetup.validate_negative_linestyle_legacy``, +- ``testing.compare.verifiers``, ``testing.compare.verify``, +- ``testing.decorators.knownfailureif``, + ``testing.decorators.ImageComparisonTest.remove_text``, +- ``tests.assert_str_equal``, ``tests.test_tinypages.file_same``, +- ``texmanager.dvipng_hack_alpha``, +- ``_AxesBase.axesPatch``, ``_AxesBase.get_cursor_props``, + ``_AxesBase.set_cursor_props``, +- ``_ImageBase.iterpnames``, +- ``Figure.figurePatch``, +- ``FigureCanvasBase.dynamic_update``, ``FigureCanvasBase.idle_event``, + ``FigureCanvasBase.get_linestyle``, ``FigureCanvasBase.set_linestyle``, +- ``FigureCanvasQTAgg.blitbox``, +- passing ``frac`` to ``PolarAxes.set_theta_grids``, diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index a5b8249f88c0..99a6dcc4b15a 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -459,23 +459,6 @@ def checkdep_ghostscript(): checkdep_ghostscript.version = None -# Deprecated, as it is unneeded and some distributions (e.g. MiKTeX 2.9.6350) -# do not actually report the TeX version. -@cbook.deprecated("2.1") -def checkdep_tex(): - try: - s = subprocess.Popen([str('tex'), '-version'], stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - stdout, stderr = s.communicate() - line = stdout.decode('ascii').split('\n')[0] - pattern = r'3\.1\d+' - match = re.search(pattern, line) - v = match.group(0) - return v - except (IndexError, ValueError, AttributeError, OSError): - return None - - def checkdep_pdftops(): try: s = subprocess.Popen([str('pdftops'), '-v'], stdout=subprocess.PIPE, @@ -509,23 +492,6 @@ def checkdep_inkscape(): checkdep_inkscape.version = None -@cbook.deprecated("2.1") -def checkdep_xmllint(): - try: - s = subprocess.Popen([str('xmllint'), '--version'], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - stdout, stderr = s.communicate() - lines = stderr.decode('ascii').split('\n') - for line in lines: - if 'version' in line: - v = line.split()[-1] - break - return v - except (IndexError, ValueError, UnboundLocalError, OSError): - return None - - def checkdep_ps_distiller(s): if not s: return False diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index f765ad0569e4..1a93adb2faee 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -40,9 +40,6 @@ rcParams = matplotlib.rcParams -is_string_like = cbook.is_string_like -is_sequence_of_strings = cbook.is_sequence_of_strings - _hold_msg = """axes.hold is deprecated. See the API Changes document (http://matplotlib.org/api/api_changes.html) for more details.""" @@ -1131,11 +1128,6 @@ def cla(self): self.stale = True - @property - @cbook.deprecated("2.1", alternative="Axes.patch") - def axesPatch(self): - return self.patch - def clear(self): """Clear the axes.""" self.cla() @@ -4043,38 +4035,6 @@ def format_deltas(key, dx, dy): self.set_xlim(points[:, 0]) self.set_ylim(points[:, 1]) - @cbook.deprecated("2.1") - def get_cursor_props(self): - """ - Return the cursor propertiess as a (*linewidth*, *color*) - tuple, where *linewidth* is a float and *color* is an RGBA - tuple - """ - return self._cursorProps - - @cbook.deprecated("2.1") - def set_cursor_props(self, *args): - """Set the cursor property as - - Call signature :: - - ax.set_cursor_props(linewidth, color) - - or:: - - ax.set_cursor_props((linewidth, color)) - - ACCEPTS: a (*float*, *color*) tuple - """ - if len(args) == 1: - lw, c = args[0] - elif len(args) == 2: - lw, c = args - else: - raise ValueError('args must be a (linewidth, color) tuple') - c = mcolors.to_rgba(c) - self._cursorProps = lw, c - def get_children(self): """return a list of child artists""" children = [] diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index 2fe2ad59ac42..59b9246698fc 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -954,14 +954,6 @@ def get_joinstyle(self): """ return self._joinstyle - @cbook.deprecated("2.1") - def get_linestyle(self): - """ - Return the linestyle: one of ('solid', 'dashed', 'dashdot', - 'dotted'). - """ - return self._linestyle - def get_linewidth(self): """ Return the line width in points as a scalar @@ -1105,17 +1097,6 @@ def set_linewidth(self, w): """ self._linewidth = float(w) - @cbook.deprecated("2.1") - def set_linestyle(self, style): - """ - Set the linestyle to be one of ('solid', 'dashed', 'dashdot', - 'dotted'). These are defined in the rcParams - `lines.dashed_pattern`, `lines.dashdot_pattern` and - `lines.dotted_pattern`. One may also specify customized dash - styles by providing a tuple of (offset, dash pairs). - """ - self._linestyle = style - def set_url(self, url): """ Sets the url for links in compatible backends @@ -1406,14 +1387,6 @@ def __init__(self, name, canvas, guiEvent=None): self.guiEvent = guiEvent -@cbook.deprecated("2.1") -class IdleEvent(Event): - """ - An event triggered by the GUI backend when it is idle -- useful - for passive animation - """ - - class DrawEvent(Event): """ An event triggered by a draw operation on the canvas @@ -2014,13 +1987,6 @@ def enter_notify_event(self, guiEvent=None, xy=None): event = Event('figure_enter_event', self, guiEvent) self.callbacks.process('figure_enter_event', event) - @cbook.deprecated("2.1") - def idle_event(self, guiEvent=None): - """Called when GUI is idle.""" - s = 'idle_event' - event = IdleEvent(s, self, guiEvent=guiEvent) - self.callbacks.process(s, event) - def grab_mouse(self, ax): """ Set the child axes which are currently grabbing the mouse events. @@ -2814,10 +2780,6 @@ def back(self, *args): self.set_history_buttons() self._update_view() - @cbook.deprecated("2.1", alternative="canvas.draw_idle") - def dynamic_update(self): - self.canvas.draw_idle() - def draw_rubberband(self, event, x0, y0, x1, y1): """Draw a rectangle rubberband to indicate zoom limits. diff --git a/lib/matplotlib/backends/backend_qt5agg.py b/lib/matplotlib/backends/backend_qt5agg.py index 4783143d83d6..4c412459712a 100644 --- a/lib/matplotlib/backends/backend_qt5agg.py +++ b/lib/matplotlib/backends/backend_qt5agg.py @@ -20,11 +20,6 @@ def __init__(self, figure): super().__init__(figure=figure) self._bbox_queue = [] - @property - @cbook.deprecated("2.1") - def blitbox(self): - return self._bbox_queue - def paintEvent(self, e): """Copy the image from the Agg canvas to the qt.drawable. diff --git a/lib/matplotlib/backends/backend_wx.py b/lib/matplotlib/backends/backend_wx.py index 81b0729b65d8..caaeb0ee6a97 100644 --- a/lib/matplotlib/backends/backend_wx.py +++ b/lib/matplotlib/backends/backend_wx.py @@ -501,27 +501,6 @@ def set_joinstyle(self, js): self.gfx_ctx.SetPen(self._pen) self.unselect() - @cbook.deprecated("2.1") - def set_linestyle(self, ls): - """ - Set the line style to be one of - """ - DEBUG_MSG("set_linestyle()", 1, self) - self.select() - GraphicsContextBase.set_linestyle(self, ls) - try: - self._style = wxc.dashd_wx[ls] - except KeyError: - self._style = wx.LONG_DASH # Style not used elsewhere... - - # On MS Windows platform, only line width of 1 allowed for dash lines - if wx.Platform == '__WXMSW__': - self.set_linewidth(1) - - self._pen.SetStyle(self._style) - self.gfx_ctx.SetPen(self._pen) - self.unselect() - def get_wxcolour(self, color): """return a wx.Colour from RGB format""" DEBUG_MSG("get_wx_color()", 1, self) @@ -1591,14 +1570,6 @@ def set_cursor(self, cursor): self.canvas.SetCursor(cursor) self.canvas.Update() - @cbook.deprecated("2.1", alternative="canvas.draw_idle") - def dynamic_update(self): - d = self._idle - self._idle = False - if d: - self.canvas.draw() - self._idle = True - def press(self, event): if self._active == 'ZOOM': if not self.retinaFix: diff --git a/lib/matplotlib/cbook/__init__.py b/lib/matplotlib/cbook/__init__.py index 1e43f4b6f3e2..5ba63c2f0158 100644 --- a/lib/matplotlib/cbook/__init__.py +++ b/lib/matplotlib/cbook/__init__.py @@ -64,87 +64,6 @@ def unicode_safe(s): return s -@deprecated('2.1') -class converter(object): - """ - Base class for handling string -> python type with support for - missing values - """ - def __init__(self, missing='Null', missingval=None): - self.missing = missing - self.missingval = missingval - - def __call__(self, s): - if s == self.missing: - return self.missingval - return s - - def is_missing(self, s): - return not s.strip() or s == self.missing - - -@deprecated('2.1') -class tostr(converter): - """convert to string or None""" - def __init__(self, missing='Null', missingval=''): - converter.__init__(self, missing=missing, missingval=missingval) - - -@deprecated('2.1') -class todatetime(converter): - """convert to a datetime or None""" - def __init__(self, fmt='%Y-%m-%d', missing='Null', missingval=None): - 'use a :func:`time.strptime` format string for conversion' - converter.__init__(self, missing, missingval) - self.fmt = fmt - - def __call__(self, s): - if self.is_missing(s): - return self.missingval - tup = time.strptime(s, self.fmt) - return datetime.datetime(*tup[:6]) - - -@deprecated('2.1') -class todate(converter): - """convert to a date or None""" - def __init__(self, fmt='%Y-%m-%d', missing='Null', missingval=None): - """use a :func:`time.strptime` format string for conversion""" - converter.__init__(self, missing, missingval) - self.fmt = fmt - - def __call__(self, s): - if self.is_missing(s): - return self.missingval - tup = time.strptime(s, self.fmt) - return datetime.date(*tup[:3]) - - -@deprecated('2.1') -class tofloat(converter): - """convert to a float or None""" - def __init__(self, missing='Null', missingval=None): - converter.__init__(self, missing) - self.missingval = missingval - - def __call__(self, s): - if self.is_missing(s): - return self.missingval - return float(s) - - -@deprecated('2.1') -class toint(converter): - """convert to an int or None""" - def __init__(self, missing='Null', missingval=None): - converter.__init__(self, missing) - - def __call__(self, s): - if self.is_missing(s): - return self.missingval - return int(s) - - class _BoundMethodProxy(object): """ Our own proxy object which enables weak references to bound and unbound @@ -502,12 +421,6 @@ class is even handier, and prettier to use. Whenever you want to pass -@deprecated('2.1') -def unique(x): - """Return a list of unique elements of *x*""" - return list(set(x)) - - def iterable(obj): """return true if *obj* is iterable""" try: @@ -517,30 +430,6 @@ def iterable(obj): return True -@deprecated('2.1') -def is_string_like(obj): - """Return True if *obj* looks like a string""" - # (np.str_ == np.unicode_ on Py3). - return isinstance(obj, (six.string_types, np.str_, np.unicode_)) - - -@deprecated('2.1') -def is_sequence_of_strings(obj): - """Returns true if *obj* is iterable and contains strings""" - if not iterable(obj): - return False - if is_string_like(obj) and not isinstance(obj, np.ndarray): - try: - obj = obj.values - except AttributeError: - # not pandas - return False - for o in obj: - if not is_string_like(o): - return False - return True - - def is_hashable(obj): """Returns true if *obj* can be hashed""" try: @@ -568,12 +457,6 @@ def file_requires_unicode(x): return False -@deprecated('2.1') -def is_scalar(obj): - """return true if *obj* is not string like and is not iterable""" - return not isinstance(obj, six.string_types) and not iterable(obj) - - @deprecated('3.0', 'isinstance(..., numbers.Number)') def is_numlike(obj): """return true if *obj* looks like a number""" @@ -700,149 +583,6 @@ def flatten(seq, scalarp=is_scalar_or_string): yield from flatten(item, scalarp) -@deprecated('2.1', "sorted(..., key=itemgetter(...))") -class Sorter(object): - """ - Sort by attribute or item - - Example usage:: - - sort = Sorter() - - list = [(1, 2), (4, 8), (0, 3)] - dict = [{'a': 3, 'b': 4}, {'a': 5, 'b': 2}, {'a': 0, 'b': 0}, - {'a': 9, 'b': 9}] - - - sort(list) # default sort - sort(list, 1) # sort by index 1 - sort(dict, 'a') # sort a list of dicts by key 'a' - - """ - - def _helper(self, data, aux, inplace): - aux.sort() - result = [data[i] for junk, i in aux] - if inplace: - data[:] = result - return result - - def byItem(self, data, itemindex=None, inplace=1): - if itemindex is None: - if inplace: - data.sort() - result = data - else: - result = sorted(data) - return result - else: - aux = [(data[i][itemindex], i) for i in range(len(data))] - return self._helper(data, aux, inplace) - - def byAttribute(self, data, attributename, inplace=1): - aux = [(getattr(data[i], attributename), i) for i in range(len(data))] - return self._helper(data, aux, inplace) - - # a couple of handy synonyms - sort = byItem - __call__ = byItem - - -@deprecated('2.1') -class Xlator(dict): - """ - All-in-one multiple-string-substitution class - - Example usage:: - - text = "Larry Wall is the creator of Perl" - adict = { - "Larry Wall" : "Guido van Rossum", - "creator" : "Benevolent Dictator for Life", - "Perl" : "Python", - } - - print(multiple_replace(adict, text)) - - xlat = Xlator(adict) - print(xlat.xlat(text)) - """ - - def _make_regex(self): - """ Build re object based on the keys of the current dictionary """ - return re.compile("|".join(map(re.escape, self))) - - def __call__(self, match): - """ Handler invoked for each regex *match* """ - return self[match.group(0)] - - def xlat(self, text): - """ Translate *text*, returns the modified text. """ - return self._make_regex().sub(self, text) - - -@deprecated('2.1') -def soundex(name, len=4): - """ soundex module conforming to Odell-Russell algorithm """ - - # digits holds the soundex values for the alphabet - soundex_digits = '01230120022455012623010202' - sndx = '' - fc = '' - - # Translate letters in name to soundex digits - for c in name.upper(): - if c.isalpha(): - if not fc: - fc = c # Remember first letter - d = soundex_digits[ord(c) - ord('A')] - # Duplicate consecutive soundex digits are skipped - if not sndx or (d != sndx[-1]): - sndx += d - - # Replace first digit with first letter - sndx = fc + sndx[1:] - - # Remove all 0s from the soundex code - sndx = sndx.replace('0', '') - - # Return soundex code truncated or 0-padded to len characters - return (sndx + (len * '0'))[:len] - - -@deprecated('2.1') -class Null(object): - """ Null objects always and reliably "do nothing." """ - - def __init__(self, *args, **kwargs): - pass - - def __call__(self, *args, **kwargs): - return self - - def __str__(self): - return "Null()" - - def __repr__(self): - return "Null()" - - if six.PY3: - def __bool__(self): - return 0 - else: - def __nonzero__(self): - return 0 - - def __getattr__(self, name): - return self - - def __setattr__(self, name, value): - return self - - def __delattr__(self, name): - return self - - @deprecated("3.0") def mkdirs(newdir, mode=0o777): """ @@ -890,91 +630,6 @@ def get_realpath_and_stat(path): return realpath, stat_key -@deprecated('2.1') -def dict_delall(d, keys): - """delete all of the *keys* from the :class:`dict` *d*""" - for key in keys: - try: - del d[key] - except KeyError: - pass - - -@deprecated('2.1') -class RingBuffer(object): - """ class that implements a not-yet-full buffer """ - def __init__(self, size_max): - self.max = size_max - self.data = [] - - class __Full: - """ class that implements a full buffer """ - def append(self, x): - """ Append an element overwriting the oldest one. """ - self.data[self.cur] = x - self.cur = (self.cur + 1) % self.max - - def get(self): - """ return list of elements in correct order """ - return self.data[self.cur:] + self.data[:self.cur] - - def append(self, x): - """append an element at the end of the buffer""" - self.data.append(x) - if len(self.data) == self.max: - self.cur = 0 - # Permanently change self's class from non-full to full - self.__class__ = __Full - - def get(self): - """ Return a list of elements from the oldest to the newest. """ - return self.data - - def __get_item__(self, i): - return self.data[i % len(self.data)] - - -@deprecated('2.1') -def get_split_ind(seq, N): - """ - *seq* is a list of words. Return the index into seq such that:: - - len(' '.join(seq[:ind])<=N - - . - """ - - s_len = 0 - # todo: use Alex's xrange pattern from the cbook for efficiency - for (word, ind) in zip(seq, xrange(len(seq))): - s_len += len(word) + 1 # +1 to account for the len(' ') - if s_len >= N: - return ind - return len(seq) - - -@deprecated('2.1', alternative='textwrap.TextWrapper') -def wrap(prefix, text, cols): - """wrap *text* with *prefix* at length *cols*""" - pad = ' ' * len(prefix.expandtabs()) - available = cols - len(pad) - - seq = text.split(' ') - Nseq = len(seq) - ind = 0 - lines = [] - while ind < Nseq: - lastInd = ind - ind += get_split_ind(seq[ind:], available) - lines.append(seq[lastInd:ind]) - - # add the prefix to the first line, pad with spaces otherwise - ret = prefix + ' '.join(lines[0]) + '\n' - for line in lines[1:]: - ret += pad + ' '.join(line) + '\n' - return ret - - # A regular expression used to determine the amount of space to # remove. It looks for the first sequence of spaces immediately # following the first newline, or at the beginning of the string. @@ -1051,101 +706,6 @@ def listFiles(root, patterns='*', recurse=1, return_folders=0): return results -@deprecated('2.1') -def get_recursive_filelist(args): - """ - Recurse all the files and dirs in *args* ignoring symbolic links - and return the files as a list of strings - """ - files = [] - - for arg in args: - if os.path.isfile(arg): - files.append(arg) - continue - if os.path.isdir(arg): - newfiles = listFiles(arg, recurse=1, return_folders=1) - files.extend(newfiles) - - return [f for f in files if not os.path.islink(f)] - - -@deprecated('2.1') -def pieces(seq, num=2): - """Break up the *seq* into *num* tuples""" - start = 0 - while 1: - item = seq[start:start + num] - if not len(item): - break - yield item - start += num - - -@deprecated('2.1') -def exception_to_str(s=None): - if six.PY3: - sh = io.StringIO() - else: - sh = io.BytesIO() - if s is not None: - print(s, file=sh) - traceback.print_exc(file=sh) - return sh.getvalue() - - -@deprecated('2.1') -def allequal(seq): - """ - Return *True* if all elements of *seq* compare equal. If *seq* is - 0 or 1 length, return *True* - """ - if len(seq) < 2: - return True - val = seq[0] - for i in xrange(1, len(seq)): - thisval = seq[i] - if thisval != val: - return False - return True - - -@deprecated('2.1') -def alltrue(seq): - """ - Return *True* if all elements of *seq* evaluate to *True*. If - *seq* is empty, return *False*. - """ - if not len(seq): - return False - for val in seq: - if not val: - return False - return True - - -@deprecated('2.1') -def onetrue(seq): - """ - Return *True* if one element of *seq* is *True*. It *seq* is - empty, return *False*. - """ - if not len(seq): - return False - for val in seq: - if val: - return True - return False - - -@deprecated('2.1') -def allpairs(x): - """ - return all possible pairs in sequence *x* - """ - return [(s, f) for i, f in enumerate(x) for s in x[i + 1:]] - - class maxdict(dict): """ A dictionary with a maximum size; this doesn't override all the @@ -1262,37 +822,6 @@ def remove(self, o): self.push(thiso) -@deprecated('2.1') -def finddir(o, match, case=False): - """ - return all attributes of *o* which match string in match. if case - is True require an exact case match. - """ - if case: - names = [(name, name) for name in dir(o) - if isinstance(name, six.string_types)] - else: - names = [(name.lower(), name) for name in dir(o) - if isinstance(name, six.string_types)] - match = match.lower() - return [orig for name, orig in names if name.find(match) >= 0] - - -@deprecated('2.1') -def reverse_dict(d): - """reverse the dictionary -- may lose data if values are not unique!""" - return {v: k for k, v in six.iteritems(d)} - - -@deprecated('2.1') -def restrict_dict(d, keys): - """ - Return a dictionary that contains those keys that appear in both - d and keys, with values from d. - """ - return {k: v for k, v in six.iteritems(d) if k in keys} - - def report_memory(i=0): # argument may go away """return the memory consumed by process""" from subprocess import Popen, PIPE @@ -1351,16 +880,6 @@ def safezip(*args): return list(zip(*args)) -@deprecated('2.1') -def issubclass_safe(x, klass): - """return issubclass(x, klass) and return False on a TypeError""" - - try: - return issubclass(x, klass) - except TypeError: - return False - - def safe_masked_invalid(x, copy=False): x = np.array(x, subok=True, copy=copy) if not x.dtype.isnative: @@ -1595,21 +1114,6 @@ def simple_linear_interpolation(a, steps): .reshape((len(x),) + a.shape[1:])) -@deprecated('2.1', alternative='shutil.rmtree') -def recursive_remove(path): - if os.path.isdir(path): - for fname in (glob.glob(os.path.join(path, '*')) + - glob.glob(os.path.join(path, '.*'))): - if os.path.isdir(fname): - recursive_remove(fname) - os.removedirs(fname) - else: - os.remove(fname) - # os.removedirs(path) - else: - os.remove(path) - - def delete_masked_points(*args): """ Find all masked and/or non-finite points in a set of arguments, @@ -1895,58 +1399,6 @@ def _compute_conf_interval(data, med, iqr, bootstrap): return bxpstats -# FIXME I don't think this is used anywhere -@deprecated('2.1') -def unmasked_index_ranges(mask, compressed=True): - """ - Find index ranges where *mask* is *False*. - - *mask* will be flattened if it is not already 1-D. - - Returns Nx2 :class:`numpy.ndarray` with each row the start and stop - indices for slices of the compressed :class:`numpy.ndarray` - corresponding to each of *N* uninterrupted runs of unmasked - values. If optional argument *compressed* is *False*, it returns - the start and stop indices into the original :class:`numpy.ndarray`, - not the compressed :class:`numpy.ndarray`. Returns *None* if there - are no unmasked values. - - Example:: - - y = ma.array(np.arange(5), mask = [0,0,1,0,0]) - ii = unmasked_index_ranges(ma.getmaskarray(y)) - # returns array [[0,2,] [2,4,]] - - y.compressed()[ii[1,0]:ii[1,1]] - # returns array [3,4,] - - ii = unmasked_index_ranges(ma.getmaskarray(y), compressed=False) - # returns array [[0, 2], [3, 5]] - - y.filled()[ii[1,0]:ii[1,1]] - # returns array [3,4,] - - Prior to the transforms refactoring, this was used to support - masked arrays in Line2D. - """ - mask = mask.reshape(mask.size) - m = np.concatenate(((1,), mask, (1,))) - indices = np.arange(len(mask) + 1) - mdif = m[1:] - m[:-1] - i0 = np.compress(mdif == -1, indices) - i1 = np.compress(mdif == 1, indices) - assert len(i0) == len(i1) - if len(i1) == 0: - return None # Maybe this should be np.zeros((0,2), dtype=int) - if not compressed: - return np.concatenate((i0[:, np.newaxis], i1[:, np.newaxis]), axis=1) - seglengths = i1 - i0 - breakpoints = np.cumsum(seglengths) - ic0 = np.concatenate(((0,), breakpoints[:-1])) - ic1 = breakpoints - return np.concatenate((ic0[:, np.newaxis], ic1[:, np.newaxis]), axis=1) - - # The ls_mapper maps short codes for line style to their full name used by # backends; the reverse mapper is for mapping full names to short ones. ls_mapper = {'-': 'solid', '--': 'dashed', '-.': 'dashdot', ':': 'dotted'} diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index ec3912fac2f5..dc29c4791046 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -400,11 +400,6 @@ def __init__(self, self._align_xlabel_grp = cbook.Grouper() self._align_ylabel_grp = cbook.Grouper() - @property - @cbook.deprecated("2.1", alternative="`.Figure.patch`") - def figurePatch(self): - return self.patch - # TODO: I'd like to dynamically add the _repr_html_ method # to the figure in the right context, but then IPython doesn't # use it, for some reason. diff --git a/lib/matplotlib/font_manager.py b/lib/matplotlib/font_manager.py index 14381abfb9df..7b7881c0b93d 100644 --- a/lib/matplotlib/font_manager.py +++ b/lib/matplotlib/font_manager.py @@ -19,7 +19,6 @@ platforms, so if a font is installed, it is much more likely to be found. """ -from __future__ import absolute_import, division, print_function import six @@ -340,24 +339,6 @@ def findSystemFonts(fontpaths=None, fontext='ttf'): return [fname for fname in fontfiles if os.path.exists(fname)] -@cbook.deprecated("2.1") -def weight_as_number(weight): - """ - Return the weight property as a numeric value. String values - are converted to their corresponding numeric value. - """ - if isinstance(weight, six.string_types): - try: - weight = weight_dict[weight.lower()] - except KeyError: - weight = 400 - elif weight in range(100, 1000, 100): - pass - else: - raise ValueError('weight not a valid integer') - return weight - - class FontEntry(object): """ A class for storing Font properties. It is used when populating @@ -922,22 +903,6 @@ def copy(self): return FontProperties(_init=self) -@cbook.deprecated("2.1") -def ttfdict_to_fnames(d): - """ - flatten a ttfdict to all the filenames it contains - """ - fnames = [] - for named in six.itervalues(d): - for styled in six.itervalues(named): - for variantd in six.itervalues(styled): - for weightd in six.itervalues(variantd): - for stretchd in six.itervalues(weightd): - for fname in six.itervalues(stretchd): - fnames.append(fname) - return fnames - - class JSONEncoder(json.JSONEncoder): def default(self, o): if isinstance(o, FontManager): diff --git a/lib/matplotlib/image.py b/lib/matplotlib/image.py index 45436619f227..b7032a03e10f 100644 --- a/lib/matplotlib/image.py +++ b/lib/matplotlib/image.py @@ -3,8 +3,6 @@ operations. """ -from __future__ import (absolute_import, division, print_function, - unicode_literals) import six from six.moves.urllib.parse import urlparse @@ -183,21 +181,6 @@ def _rgb_to_rgba(A): class _ImageBase(martist.Artist, cm.ScalarMappable): zorder = 0 - @property - @cbook.deprecated("2.1") - def _interpd(self): - return _interpd_ - - @property - @cbook.deprecated("2.1") - def _interpdr(self): - return {v: k for k, v in six.iteritems(_interpd_)} - - @property - @cbook.deprecated("2.1", alternative="mpl.image.interpolation_names") - def iterpnames(self): - return interpolations_names - def __str__(self): return "AxesImage(%g,%g;%gx%g)" % tuple(self.axes.bbox.bounds) diff --git a/lib/matplotlib/projections/polar.py b/lib/matplotlib/projections/polar.py index 1493d7b3fc02..e32a2ace9588 100644 --- a/lib/matplotlib/projections/polar.py +++ b/lib/matplotlib/projections/polar.py @@ -1226,8 +1226,7 @@ def set_rticks(self, *args, **kwargs): return Axes.set_yticks(self, *args, **kwargs) @docstring.dedent_interpd - def set_thetagrids(self, angles, labels=None, frac=None, fmt=None, - **kwargs): + def set_thetagrids(self, angles, labels=None, fmt=None, **kwargs): """ Set the angles at which to place the theta grids (these gridlines are equal along the theta dimension). *angles* is in @@ -1238,10 +1237,6 @@ def set_thetagrids(self, angles, labels=None, frac=None, fmt=None, If *labels* is None, the labels will be ``fmt %% angle`` - *frac* is the fraction of the polar axes radius at which to - place the label (1 is the edge). e.g., 1.05 is outside the axes - and 0.95 is inside the axes. - Return value is a list of tuples (*line*, *label*), where *line* is :class:`~matplotlib.lines.Line2D` instances and the *label* is :class:`~matplotlib.text.Text` instances. @@ -1252,10 +1247,6 @@ def set_thetagrids(self, angles, labels=None, frac=None, fmt=None, ACCEPTS: sequence of floats """ - if frac is not None: - cbook.warn_deprecated('2.1', name='frac', obj_type='parameter', - alternative='tick padding via ' - 'Axes.tick_params') # Make sure we take into account unitized data angles = self.convert_yunits(angles) diff --git a/lib/matplotlib/pylab.py b/lib/matplotlib/pylab.py index abfa09c674f4..5c90445bfaec 100644 --- a/lib/matplotlib/pylab.py +++ b/lib/matplotlib/pylab.py @@ -213,8 +213,7 @@ """ -from matplotlib.cbook import ( - flatten, exception_to_str, silent_list, iterable, dedent) +from matplotlib.cbook import flatten, silent_list, iterable, dedent import matplotlib as mpl diff --git a/lib/matplotlib/pyplot.py b/lib/matplotlib/pyplot.py index c89d41f9589c..791c9bf90ad9 100644 --- a/lib/matplotlib/pyplot.py +++ b/lib/matplotlib/pyplot.py @@ -1865,56 +1865,6 @@ def get_plot_commands(): and inspect.getmodule(obj) is this_module) -@deprecated('2.1') -def colors(): - """ - This is a do-nothing function to provide you with help on how - matplotlib handles colors. - - Commands which take color arguments can use several formats to - specify the colors. For the basic built-in colors, you can use a - single letter - - ===== ======= - Alias Color - ===== ======= - 'b' blue - 'g' green - 'r' red - 'c' cyan - 'm' magenta - 'y' yellow - 'k' black - 'w' white - ===== ======= - - For a greater range of colors, you have two options. You can - specify the color using an html hex string, as in:: - - color = '#eeefff' - - or you can pass an R,G,B tuple, where each of R,G,B are in the - range [0,1]. - - You can also use any legal html name for a color, for example:: - - color = 'red' - color = 'burlywood' - color = 'chartreuse' - - The example below creates a subplot with a dark - slate gray background:: - - subplot(111, facecolor=(0.1843, 0.3098, 0.3098)) - - Here is an example that creates a pale turquoise title:: - - title('Is this the best color?', color='#afeeee') - - """ - pass - - def colormaps(): """ Matplotlib provides a number of colormaps, and others can be added using diff --git a/lib/matplotlib/rcsetup.py b/lib/matplotlib/rcsetup.py index a4434f1ba5d4..b0a9b16c2e6b 100644 --- a/lib/matplotlib/rcsetup.py +++ b/lib/matplotlib/rcsetup.py @@ -539,26 +539,6 @@ def validate_ps_distiller(s): ignorecase=True) -@deprecated('2.1', - addendum=(" See 'validate_negative_linestyle_legacy' " + - "deprecation warning for more information.")) -def validate_negative_linestyle(s): - return _validate_negative_linestyle(s) - - -@deprecated('2.1', - addendum=(" The 'contour.negative_linestyle' rcParam now " + - "follows the same validation as the other rcParams " + - "that are related to line style.")) -def validate_negative_linestyle_legacy(s): - try: - res = validate_negative_linestyle(s) - return res - except ValueError: - dashes = validate_nseq_float(2)(s) - return (0, dashes) # (offset, (solid, blank)) - - validate_legend_loc = ValidateInStrings( 'legend_loc', ['best', diff --git a/lib/matplotlib/sphinxext/tests/test_tinypages.py b/lib/matplotlib/sphinxext/tests/test_tinypages.py index 748a3f381900..9ec300894760 100644 --- a/lib/matplotlib/sphinxext/tests/test_tinypages.py +++ b/lib/matplotlib/sphinxext/tests/test_tinypages.py @@ -15,15 +15,6 @@ reason="'{} -msphinx' does not return 0".format(sys.executable)) -@cbook.deprecated("2.1", alternative="filecmp.cmp") -def file_same(file1, file2): - with open(file1, 'rb') as fobj: - contents1 = fobj.read() - with open(file2, 'rb') as fobj: - contents2 = fobj.read() - return contents1 == contents2 - - def test_tinypages(tmpdir): html_dir = pjoin(str(tmpdir), 'html') doctree_dir = pjoin(str(tmpdir), 'doctrees') diff --git a/lib/matplotlib/testing/compare.py b/lib/matplotlib/testing/compare.py index e19ecb47a577..7c24b6141698 100644 --- a/lib/matplotlib/testing/compare.py +++ b/lib/matplotlib/testing/compare.py @@ -316,39 +316,6 @@ def convert(filename, cache): return newname -#: Maps file extensions to a function which takes a filename as its -#: only argument to return a list suitable for execution with Popen. -#: The purpose of this is so that the result file (with the given -#: extension) can be verified with tools such as xmllint for svg. -verifiers = {} - -# Turning this off, because it seems to cause multiprocessing issues -if False and matplotlib.checkdep_xmllint(): - verifiers['svg'] = lambda filename: [ - 'xmllint', '--valid', '--nowarning', '--noout', filename] - - -@cbook.deprecated("2.1") -def verify(filename): - """Verify the file through some sort of verification tool.""" - if not os.path.exists(filename): - raise IOError("'%s' does not exist" % filename) - base, extension = filename.rsplit('.', 1) - verifier = verifiers.get(extension, None) - if verifier is not None: - cmd = verifier(filename) - pipe = subprocess.Popen(cmd, universal_newlines=True, - stdout=subprocess.PIPE, stderr=subprocess.PIPE) - stdout, stderr = pipe.communicate() - errcode = pipe.wait() - if errcode != 0: - msg = "File verification command failed:\n%s\n" % ' '.join(cmd) - if stdout: - msg += "Standard output:\n%s\n" % stdout - if stderr: - msg += "Standard error:\n%s\n" % stderr - raise IOError(msg) - def crop_to_same(actual_path, actual_image, expected_path, expected_image): # clip the images to the same size -- this is useful only when diff --git a/lib/matplotlib/testing/decorators.py b/lib/matplotlib/testing/decorators.py index 403d273ccfd7..407592af834d 100644 --- a/lib/matplotlib/testing/decorators.py +++ b/lib/matplotlib/testing/decorators.py @@ -55,12 +55,6 @@ def _knownfailureif(fail_condition, msg=None, known_exception_class=None): return knownfailureif(fail_condition, msg, known_exception_class) -@cbook.deprecated('2.1', - alternative='pytest.xfail or import the plugin') -def knownfailureif(fail_condition, msg=None, known_exception_class=None): - _knownfailureif(fail_condition, msg, known_exception_class) - - def _do_cleanup(original_units_registry, original_settings): plt.close('all') @@ -330,12 +324,6 @@ def setup(self): def teardown(self): self.teardown_class() - @staticmethod - @cbook.deprecated('2.1', - alternative='remove_ticks_and_titles') - def remove_text(figure): - remove_ticks_and_titles(figure) - def nose_runner(self): func = self.compare func = _checked_on_freetype_version(self.freetype_version)(func) diff --git a/lib/matplotlib/tests/__init__.py b/lib/matplotlib/tests/__init__.py index 271e67ad6422..61261b57b6b0 100644 --- a/lib/matplotlib/tests/__init__.py +++ b/lib/matplotlib/tests/__init__.py @@ -17,22 +17,3 @@ 'This is most likely because the test data is not installed. ' 'You may need to install matplotlib from source to get the ' 'test data.') - - -@cbook.deprecated("2.1") -def assert_str_equal(reference_str, test_str, - format_str=('String {str1} and {str2} do not ' - 'match:\n{differences}')): - """ - Assert the two strings are equal. If not, fail and print their - diffs using difflib. - - """ - if reference_str != test_str: - diff = difflib.unified_diff(reference_str.splitlines(1), - test_str.splitlines(1), - 'Reference', 'Test result', - '', '', 0) - raise ValueError(format_str.format(str1=reference_str, - str2=test_str, - differences=''.join(diff))) diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 303d2f183009..abd2b6675b48 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -5573,15 +5573,6 @@ def test_zero_linewidth(): plt.plot([0, 1], [0, 1], ls='--', lw=0) -def test_patch_deprecations(): - fig, ax = plt.subplots() - with warnings.catch_warnings(record=True) as w: - assert ax.patch == ax.axesPatch - assert fig.patch == fig.figurePatch - - assert len(w) == 2 - - def test_polar_gridlines(): fig = plt.figure() ax = fig.add_subplot(111, polar=True) diff --git a/lib/matplotlib/tests/test_cbook.py b/lib/matplotlib/tests/test_cbook.py index b7750b2bc9a9..aa5e3f9f620c 100644 --- a/lib/matplotlib/tests/test_cbook.py +++ b/lib/matplotlib/tests/test_cbook.py @@ -26,24 +26,6 @@ def test_is_hashable(): assert not cbook.is_hashable(lst) -def test_restrict_dict(): - d = {'foo': 'bar', 1: 2} - with pytest.warns(cbook.deprecation.MatplotlibDeprecationWarning) as rec: - d1 = cbook.restrict_dict(d, ['foo', 1]) - assert d1 == d - d2 = cbook.restrict_dict(d, ['bar', 2]) - assert d2 == {} - d3 = cbook.restrict_dict(d, {'foo': 1}) - assert d3 == {'foo': 'bar'} - d4 = cbook.restrict_dict(d, {}) - assert d4 == {} - d5 = cbook.restrict_dict(d, {'foo', 2}) - assert d5 == {'foo': 'bar'} - assert len(rec) == 5 - # check that d was not modified - assert d == {'foo': 'bar', 1: 2} - - class Test_delete_masked_points(object): def setup_method(self): self.mask1 = [False, False, True, True, False, False] diff --git a/lib/matplotlib/tests/test_compare_images.py b/lib/matplotlib/tests/test_compare_images.py index 526eb0336149..83ca0d99413b 100644 --- a/lib/matplotlib/tests/test_compare_images.py +++ b/lib/matplotlib/tests/test_compare_images.py @@ -96,19 +96,6 @@ def nosetest_simple_figure(): return fig -def nosetest_manual_text_removal(): - from matplotlib.testing.decorators import ImageComparisonTest - - fig = nosetest_simple_figure() - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter('always') - # Make sure this removes text like it should. - ImageComparisonTest.remove_text(fig) - - assert len(w) == 1 - assert 'remove_text function was deprecated in version 2.1.' in str(w[0]) - - @pytest.mark.parametrize( 'func, kwargs, errors, failures, dots', [ @@ -134,11 +121,6 @@ def nosetest_manual_text_removal(): [], [], '...'), - (nosetest_manual_text_removal, - {'baseline_images': ['simple']}, - [], - [], - '...'), ], ids=[ 'empty', @@ -146,7 +128,6 @@ def nosetest_manual_text_removal(): 'incorrect shape', 'failing figure', 'passing figure', - 'manual text removal', ]) def test_nose_image_comparison(func, kwargs, errors, failures, dots, monkeypatch): diff --git a/lib/matplotlib/tests/test_image.py b/lib/matplotlib/tests/test_image.py index 26e3b4a7ea26..d332ca0f3ef3 100644 --- a/lib/matplotlib/tests/test_image.py +++ b/lib/matplotlib/tests/test_image.py @@ -910,14 +910,6 @@ def test_imshow_bool(): ax.imshow(np.array([[True, False], [False, True]], dtype=bool)) -def test_imshow_deprecated_interd_warn(): - im = plt.imshow([[1, 2], [3, np.nan]]) - for k in ('_interpd', '_interpdr', 'iterpnames'): - with warnings.catch_warnings(record=True) as warns: - getattr(im, k) - assert len(warns) == 1 - - def test_full_invalid(): x = np.ones((10, 10)) x[:] = np.nan diff --git a/lib/matplotlib/texmanager.py b/lib/matplotlib/texmanager.py index 8f6273b367f8..1bd992939923 100644 --- a/lib/matplotlib/texmanager.py +++ b/lib/matplotlib/texmanager.py @@ -33,8 +33,6 @@ """ -from __future__ import absolute_import, division, print_function - import six import copy