summaryrefslogtreecommitdiff
path: root/numpy/lib/function_base.py
diff options
context:
space:
mode:
authorFrederick Lefebvre <fredlef@amazon.com>2018-03-14 03:33:05 +0000
committerfredlef <fredlef@amazon.com>2018-03-14 13:14:55 -0700
commit53b358ce7eddf78ac2bc22045fbe25e91e663b9a (patch)
tree37054f48b52d3725f7b1f6a840fd0f0d40ba2399 /numpy/lib/function_base.py
parenta91f61a429e35a47f6faa025ceb862664dc12609 (diff)
downloadpython-numpy-53b358ce7eddf78ac2bc22045fbe25e91e663b9a.tar.gz
python-numpy-53b358ce7eddf78ac2bc22045fbe25e91e663b9a.tar.bz2
python-numpy-53b358ce7eddf78ac2bc22045fbe25e91e663b9a.zip
TST: Import abstract classes from collections.abc
Abstract collection classes accessed from the collections module have been deprecated since Python 3.3. They should be accessed through collections.abc. When run with Python 3.7, the deprecation warning cause multiple tests to fail.
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r--numpy/lib/function_base.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py
index 422a87322..07b845e2b 100644
--- a/numpy/lib/function_base.py
+++ b/numpy/lib/function_base.py
@@ -1,6 +1,11 @@
from __future__ import division, absolute_import, print_function
-import collections
+try:
+ # Accessing collections abstact classes from collections
+ # has been deprecated since Python 3.3
+ import collections.abc as collections_abc
+except ImportError:
+ import collections as collections_abc
import re
import sys
import warnings
@@ -547,7 +552,7 @@ def piecewise(x, condlist, funclist, *args, **kw):
y = zeros(x.shape, x.dtype)
for k in range(n):
item = funclist[k]
- if not isinstance(item, collections.Callable):
+ if not isinstance(item, collections_abc.Callable):
y[condlist[k]] = item
else:
vals = x[condlist[k]]