diff --git a/IPython/html/services/contents/tests/test_contents_api.py b/IPython/html/services/contents/tests/test_contents_api.py
index 6d30513..c5ac049 100644
--- a/IPython/html/services/contents/tests/test_contents_api.py
+++ b/IPython/html/services/contents/tests/test_contents_api.py
@@ -24,9 +24,16 @@ from IPython.nbformat.v4 import (
)
from IPython.nbformat import v2
from IPython.utils import py3compat
-from IPython.utils.data import uniq_stable
from IPython.utils.tempdir import TemporaryDirectory
+def uniq_stable(elems):
+ """uniq_stable(elems) -> list
+
+ Return from an iterable, a list of all the unique elements in the input,
+ maintaining the order in which they first appear.
+ """
+ seen = set()
+ return [x for x in elems if x not in seen and not seen.add(x)]
def notebooks_only(dir_model):
return [nb for nb in dir_model['content'] if nb['type']=='notebook']
diff --git a/ipython_kernel/serialize.py b/ipython_kernel/serialize.py
index 1ad9f39..fd3d7ab 100644
--- a/ipython_kernel/serialize.py
+++ b/ipython_kernel/serialize.py
@@ -10,9 +10,9 @@ except:
cPickle = None
import pickle
-# IPython imports
+from itertools import chain
+
from IPython.utils.py3compat import PY3, buffer_to_bytes_py2
-from IPython.utils.data import flatten
from ipython_kernel.pickleutil import (
can, uncan, can_sequence, uncan_sequence, CannedObject,
istype, sequence_types, PICKLE_PROTOCOL,
@@ -138,10 +138,12 @@ def pack_apply_message(f, args, kwargs, buffer_threshold=MAX_BYTES, item_thresho
With length at least two + len(args) + len(kwargs)
"""
- arg_bufs = flatten(serialize_object(arg, buffer_threshold, item_threshold) for arg in args)
+ arg_bufs = list(chain.from_iterable(
+ serialize_object(arg, buffer_threshold, item_threshold) for arg in args))
kw_keys = sorted(kwargs.keys())
- kwarg_bufs = flatten(serialize_object(kwargs[key], buffer_threshold, item_threshold) for key in kw_keys)
+ kwarg_bufs = list(chain.from_iterable(
+ serialize_object(kwargs[key], buffer_threshold, item_threshold) for key in kw_keys))
info = dict(nargs=len(args), narg_bufs=len(arg_bufs), kw_keys=kw_keys)
diff --git a/ipython_parallel/client/map.py b/ipython_parallel/client/map.py
index 67b5b29..a3b908a 100644
--- a/ipython_parallel/client/map.py
+++ b/ipython_parallel/client/map.py
@@ -12,10 +12,7 @@ pieces to individual nodes in a cluster.
from __future__ import division
import sys
-from itertools import islice
-
-from IPython.utils.data import flatten as utils_flatten
-
+from itertools import islice, chain
numpy = None
@@ -75,7 +72,7 @@ class Map(object):
return numpy.concatenate(listOfPartitions)
# Next try for Python sequence types
if isinstance(testObject, (list, tuple)):
- return utils_flatten(listOfPartitions)
+ return list(chain.from_iterable(listOfPartitions))
# If we have scalars, just return listOfPartitions
return listOfPartitions
@@ -125,5 +122,3 @@ def mappable(obj):
dists = {'b':Map,'r':RoundRobinMap}
-
-
diff --git a/jupyter_client/localinterfaces.py b/jupyter_client/localinterfaces.py
index 7480f24..40b8dfa 100644
--- a/jupyter_client/localinterfaces.py
+++ b/jupyter_client/localinterfaces.py
@@ -1,6 +1,6 @@
"""Utilities for identifying local IP addresses."""
-# Copyright (c) IPython Development Team.
+# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import os
@@ -8,7 +8,6 @@ import re
import socket
from subprocess import Popen, PIPE
-from IPython.utils.data import uniq_stable
from warnings import warn
@@ -17,6 +16,18 @@ PUBLIC_IPS = []
LOCALHOST = ''
+
+def _uniq_stable(elems):
+ """uniq_stable(elems) -> list
+
+ Return from an iterable, a list of all the unique elements in the input,
+ maintaining the order in which they first appear.
+
+ From IPython.utils.data
+ """
+ seen = set()
+ return [x for x in elems if x not in seen and not seen.add(x)]
+
def _get_output(cmd):
"""Get output of a command, raising IOError if it fails"""
p = Popen(cmd, stdout=PIPE, stderr=PIPE)
@@ -69,8 +80,8 @@ def _populate_from_list(addrs):
local_ips.extend(['0.0.0.0', ''])
- LOCAL_IPS[:] = uniq_stable(local_ips)
- PUBLIC_IPS[:] = uniq_stable(public_ips)
+ LOCAL_IPS[:] = _uniq_stable(local_ips)
+ PUBLIC_IPS[:] = _uniq_stable(public_ips)
def _load_ips_ifconfig():
"""load ip addresses from `ifconfig` output (posix)"""
@@ -145,8 +156,8 @@ def _load_ips_netifaces():
LOCALHOST = '127.0.0.1'
local_ips.insert(0, LOCALHOST)
local_ips.extend(['0.0.0.0', ''])
- LOCAL_IPS[:] = uniq_stable(local_ips)
- PUBLIC_IPS[:] = uniq_stable(public_ips)
+ LOCAL_IPS[:] = _uniq_stable(local_ips)
+ PUBLIC_IPS[:] = _uniq_stable(public_ips)
def _load_ips_gethostbyname():
@@ -170,13 +181,13 @@ def _load_ips_gethostbyname():
except socket.error:
pass
finally:
- PUBLIC_IPS[:] = uniq_stable(PUBLIC_IPS)
+ PUBLIC_IPS[:] = _uniq_stable(PUBLIC_IPS)
LOCAL_IPS.extend(PUBLIC_IPS)
# include all-interface aliases: 0.0.0.0 and ''
LOCAL_IPS.extend(['0.0.0.0', ''])
- LOCAL_IPS[:] = uniq_stable(LOCAL_IPS)
+ LOCAL_IPS[:] = _uniq_stable(LOCAL_IPS)
LOCALHOST = LOCAL_IPS[0]