From f767e1e6b719a7688a28d2be356b22d877334339 Mon Sep 17 00:00:00 2001 From: Matthew Farrellee Date: Sat, 21 Mar 2020 04:15:40 -0400 Subject: [PATCH] use collections.abc for Mapping (#2750) * use collections.abc.Mapping when available * ignore py2, tox -e py27-linux revealed setup.py requires python 3.5 * use collections.abc.Iterable --- gensim/corpora/dictionary.py | 3 ++- gensim/models/doc2vec.py | 3 ++- gensim/models/fasttext.py | 2 +- gensim/test/test_corpora_dictionary.py | 3 +-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/gensim/corpora/dictionary.py b/gensim/corpora/dictionary.py index 2ba296b115..ba3795062d 100644 --- a/gensim/corpora/dictionary.py +++ b/gensim/corpora/dictionary.py @@ -8,7 +8,8 @@ from __future__ import with_statement -from collections import Mapping, defaultdict +from collections import defaultdict +from collections.abc import Mapping import sys import logging import itertools diff --git a/gensim/models/doc2vec.py b/gensim/models/doc2vec.py index 0030023b36..c5cb5b40a2 100644 --- a/gensim/models/doc2vec.py +++ b/gensim/models/doc2vec.py @@ -70,7 +70,8 @@ except ImportError: from Queue import Queue # noqa:F401 -from collections import namedtuple, defaultdict, Iterable +from collections import namedtuple, defaultdict +from collections.abc import Iterable from timeit import default_timer from numpy import zeros, float32 as REAL, empty, ones, \ diff --git a/gensim/models/fasttext.py b/gensim/models/fasttext.py index 2e4ad5fa64..d2da493ec9 100644 --- a/gensim/models/fasttext.py +++ b/gensim/models/fasttext.py @@ -285,7 +285,7 @@ import numpy as np from numpy import ones, vstack, float32 as REAL import six -from collections import Iterable +from collections.abc import Iterable import gensim.models._fasttext_bin diff --git a/gensim/test/test_corpora_dictionary.py b/gensim/test/test_corpora_dictionary.py index 29338ad45e..1791e96bb5 100644 --- a/gensim/test/test_corpora_dictionary.py +++ b/gensim/test/test_corpora_dictionary.py @@ -7,8 +7,7 @@ Unit tests for the `corpora.Dictionary` class. """ - -from collections import Mapping +from collections.abc import Mapping from itertools import chain import logging import unittest