Skip to content

Merge pull request #11786 from timhoffm/collections-abc #15191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@
import six

import atexit
from collections import MutableMapping
try:
from collections.abc import MutableMapping
except ImportError:
from collections import MutableMapping
import contextlib
import distutils.version
import functools
Expand Down
13 changes: 10 additions & 3 deletions lib/matplotlib/cbook/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
import six
from six.moves import xrange, zip
import collections
try:
import collections.abc as cabc
except ImportError:
import collections as cabc

import contextlib
import datetime
import errno
Expand Down Expand Up @@ -2293,7 +2298,8 @@ def pts_to_midstep(x, *args):
The x location of the steps. May be empty.

y1, ..., yp : array
y arrays to be turned into steps; all must be the same length as ``x``.
y arrays to be turned into steps; all must be the same length as
``x``.

Returns
-------
Expand Down Expand Up @@ -2352,7 +2358,7 @@ def index_of(y):


def safe_first_element(obj):
if isinstance(obj, collections.Iterator):
if isinstance(obj, cabc.Iterator):
# needed to accept `array.flat` as input.
# np.flatiter reports as an instance of collections.Iterator
# but can still be indexed via [].
Expand All @@ -2369,7 +2375,8 @@ def safe_first_element(obj):

def sanitize_sequence(data):
"""Converts dictview object to list"""
return list(data) if isinstance(data, collections.MappingView) else data
return (list(data) if isinstance(data, cabc.MappingView)
else data)


def normalize_kwargs(kw, alias_mapping=None, required=(), forbidden=(),
Expand Down
5 changes: 4 additions & 1 deletion lib/matplotlib/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@
import six
from six.moves import zip

from collections import Sized
try:
from collections.abc import Sized
except ImportError:
from collections import Sized
import itertools
import re
import warnings
Expand Down
6 changes: 4 additions & 2 deletions lib/matplotlib/markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,10 @@

import six
from six.moves import xrange

from collections import Sized
try:
from collections.abc import Sized
except ImportError:
from collections import Sized

import numpy as np

Expand Down
6 changes: 4 additions & 2 deletions lib/matplotlib/rcsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
from __future__ import absolute_import, division, print_function

import six

from collections import Iterable, Mapping
try:
from collections.abc import Iterable, Mapping
except ImportError:
from collections import Iterable, Mapping
from functools import reduce
import operator
import os
Expand Down