Skip to content

Commit 9c8f2d8

Browse files
committed
remove use of ipython_genutils
and various bits of py2/py3 dead code
1 parent ff90cf2 commit 9c8f2d8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+212
-469
lines changed

.flake8

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@
55
# C: complexity
66
# F401: module imported but unused
77
# F403: import *
8-
# F811: redefinition of unused `name` from line `N`
98
# F841: local variable assigned but never used
109
# E402: module level import not at top of file
1110
# I100: Import statements are in the wrong order
1211
# I101: Imported names are in the wrong order. Should be
13-
ignore = E, C, W, F401, F403, F811, F841, E402, I100, I101, D400
12+
ignore = E, C, W, F403, F841, E402, I100, I101, D400
1413
builtins = c, get_config
1514
exclude =
1615
.cache,

docs/source/conf.py

-5
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,10 @@
1414
#
1515
# All configuration values have a default; values that are commented out
1616
# serve to show the default.
17-
import os
18-
import shlex
19-
import sys
20-
2117
# If extensions (or modules to document with autodoc) are in another directory,
2218
# add these directories to sys.path here. If the directory is relative to the
2319
# documentation root, use os.path.abspath to make it absolute, like shown here.
2420
# sys.path.insert(0, os.path.abspath('.'))
25-
2621
# We load the ipython release info into a dict by explicit execution
2722
iprelease = {}
2823
exec(

docs/source/examples/Using Dill.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@
495495
"import ipyparallel as ipp\n",
496496
"\n",
497497
"@interactive\n",
498-
"class C(object):\n",
498+
"class C:\n",
499499
" a = 5\n",
500500
"\n",
501501
"@ipp.interactive\n",

docs/source/examples/customresults.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@
1010
* MinRK
1111
"""
1212
import random
13-
import time
1413

15-
import ipyparallel as parallel
14+
import ipyparallel as ipp
1615

1716
# create client & views
18-
rc = parallel.Client()
17+
rc = ipp.Client()
1918
dv = rc[:]
2019
v = rc.load_balanced_view()
2120

@@ -41,7 +40,7 @@ def sleep_here(count, t):
4140
while pending:
4241
try:
4342
rc.wait(pending, 1e-3)
44-
except parallel.TimeoutError:
43+
except TimeoutError:
4544
# ignore timeouterrors, since they only mean that at least one isn't done
4645
pass
4746
# finished is the set of msg_ids that are complete

docs/source/examples/daVinci Word Count/pwordfreq.py

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import io
99
import os
1010
import time
11-
import urllib
1211
from itertools import repeat
1312

1413
import requests

docs/source/examples/daVinci Word Count/wordfreq.py

-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
"""Count the frequencies of words in a string"""
2-
from __future__ import division
3-
from __future__ import print_function
4-
5-
import cmath as math
62

73

84
def wordfreq(text, is_filename=False):

docs/source/examples/dagdeps.py

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
* MinRK
88
"""
99
from random import randint
10-
from random import random
1110

1211
import networkx as nx
1312

docs/source/examples/fetchparse.py

+5-16
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,18 @@
1010
1111
ipcluster start -n 4
1212
"""
13-
from __future__ import print_function
14-
1513
import sys
1614
import time
1715

18-
import bs4 # this isn't necessary, but it helps throw the dependency error earlier
16+
import bs4 # noqa this isn't necessary, but it helps throw the dependency error earlier
1917

2018
import ipyparallel as ipp
2119

22-
try:
23-
raw_input
24-
except NameError:
25-
raw_input = input
26-
2720

2821
def fetchAndParse(url, data=None):
2922
import requests
30-
31-
try:
32-
from urllib.parse import urljoin
33-
except ImportError:
34-
from urlparse import urljoin
35-
import bs4
23+
from urllib.parse import urljoin
24+
import bs4 # noqa
3625

3726
links = []
3827
r = requests.get(url, data=data)
@@ -46,7 +35,7 @@ def fetchAndParse(url, data=None):
4635
return links
4736

4837

49-
class DistributedSpider(object):
38+
class DistributedSpider:
5039

5140
# Time to wait between polling for task results.
5241
pollingDelay = 0.5
@@ -103,7 +92,7 @@ def main():
10392
if len(sys.argv) > 1:
10493
site = sys.argv[1]
10594
else:
106-
site = raw_input('Enter site to crawl: ')
95+
site = input('Enter site to crawl: ')
10796
distributedSpider = DistributedSpider(site)
10897
distributedSpider.run()
10998

docs/source/examples/interengine/bintree.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def disambiguate_dns_url(url, location):
114114
return disambiguate_url(url, location)
115115

116116

117-
class BinaryTreeCommunicator(object):
117+
class BinaryTreeCommunicator:
118118

119119
id = None
120120
pub = None

docs/source/examples/interengine/communicator.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from ipyparallel.util import disambiguate_url
77

88

9-
class EngineCommunicator(object):
9+
class EngineCommunicator:
1010
def __init__(self, interface='tcp://*', identity=None):
1111
self._ctx = zmq.Context()
1212
self.socket = self._ctx.socket(zmq.XREP)

docs/source/examples/interengine/interengine.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import sys
2-
31
import ipyparallel as ipp
42

53

docs/source/examples/phistogram.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
"""Parallel histogram function"""
2-
import numpy
3-
42
from ipyparallel import Reference
53

64

docs/source/examples/pi/parallelpi.py

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
from timeit import default_timer as clock
2121

22-
import numpy as np
2322
from matplotlib import pyplot as plt
2423
from pidigits import compute_two_digit_freqs
2524
from pidigits import fetch_pi_file

docs/source/examples/pi/pidigits.py

+2-9
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,19 @@
1414
If the digits of pi are truly random, these frequencies
1515
should be equal.
1616
"""
17-
# Import statements
18-
from __future__ import division
19-
from __future__ import with_statement
17+
import os
18+
from urllib.request import urlretrieve
2019

2120
import numpy as np
2221
from matplotlib import pyplot as plt
2322

24-
try: # python2
25-
from urllib import urlretrieve
26-
except ImportError: # python3
27-
from urllib.request import urlretrieve
28-
2923
# Top-level functions
3024

3125

3226
def fetch_pi_file(filename):
3327
"""This will download a segment of pi from super-computing.org
3428
if the file is not already present.
3529
"""
36-
import os, urllib
3730

3831
ftpdir = "ftp://pi.super-computing.org/.2/pi200m/"
3932
if os.path.exists(filename):

docs/source/examples/task_profiler.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@
1616
overhead of a single task is about 0.001-0.01 seconds.
1717
"""
1818
import random
19-
import sys
19+
import time
2020
from optparse import OptionParser
2121

22-
from IPython.utils.timing import time
23-
2422
import ipyparallel as ipp
2523

2624

@@ -54,8 +52,6 @@ def main():
5452
print(view)
5553
rc.block = True
5654
nengines = len(rc.ids)
57-
with rc[:].sync_imports():
58-
from IPython.utils.timing import time
5955

6056
# the jobs should take a random time within a range
6157
times = [
@@ -68,10 +64,10 @@ def main():
6864
% (opts.n, stime, nengines)
6965
)
7066
time.sleep(1)
71-
start = time.time()
67+
start = time.perf_counter()
7268
amr = view.map(time.sleep, times)
7369
amr.get()
74-
stop = time.time()
70+
stop = time.perf_counter()
7571

7672
ptime = stop - start
7773
scale = stime / ptime

docs/source/examples/wave2D/RectPartitioner.py

-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
"""
1818
from __future__ import print_function
1919

20-
import time
21-
2220
from numpy import ascontiguousarray
2321
from numpy import frombuffer
2422
from numpy import zeros

docs/source/examples/wave2D/communicator.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from ipyparallel.util import disambiguate_url
88

99

10-
class EngineCommunicator(object):
10+
class EngineCommunicator:
1111
"""An object that connects Engines to each other.
1212
north and east sockets listen, while south and west sockets connect.
1313

docs/source/examples/wave2D/parallelwave-mpi.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,10 @@
2121
* Min Ragan-Kelley
2222
2323
"""
24-
import sys
24+
import argparse
2525
import time
2626

27-
from IPython.external import argparse
28-
from numpy import exp
29-
from numpy import newaxis
3027
from numpy import sqrt
31-
from numpy import zeros
3228

3329
import ipyparallel as ipp
3430

docs/source/examples/wave2D/parallelwave.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,10 @@
2121
* Min Ragan-Kelley
2222
2323
"""
24-
#
25-
import sys
24+
import argparse
2625
import time
2726

28-
from IPython.external import argparse
29-
from numpy import exp
30-
from numpy import newaxis
3127
from numpy import sqrt
32-
from numpy import zeros
3328

3429
import ipyparallel as ipp
3530

docs/source/examples/wave2D/wavesolver.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import time
1414

1515
from numpy import arange
16-
from numpy import exp
1716
from numpy import newaxis
1817
from numpy import sqrt
1918
from numpy import zeros
@@ -32,7 +31,7 @@ def iseq(start=0, stop=None, inc=1):
3231
return arange(start, stop + inc, inc)
3332

3433

35-
class WaveSolver(object):
34+
class WaveSolver:
3635
"""
3736
Solve the 2D wave equation u_tt = u_xx + u_yy + f(x,y,t) with
3837
u = bc(x,y,t) on the boundary and initial condition du/dt = 0.

ipyparallel/__init__.py

+12-16
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,20 @@
22
"""The IPython ZMQ-based parallel computing interface."""
33
# Copyright (c) IPython Development Team.
44
# Distributed under the terms of the Modified BSD License.
5-
import os
6-
import warnings
7-
8-
import zmq
95
from traitlets.config.configurable import MultipleInstanceError
106

11-
from ._version import __version__
12-
from ._version import version_info
13-
from .client.asyncresult import *
14-
from .client.client import Client
15-
from .client.remotefunction import *
16-
from .client.view import *
17-
from .cluster import Cluster
18-
from .cluster import ClusterManager
19-
from .controller.dependency import *
20-
from .error import *
21-
from .serialize import *
22-
from .util import interactive
7+
from ._version import __version__ # noqa
8+
from ._version import version_info # noqa
9+
from .client.asyncresult import * # noqa
10+
from .client.client import Client # noqa
11+
from .client.remotefunction import * # noqa
12+
from .client.view import * # noqa
13+
from .cluster import Cluster # noqa
14+
from .cluster import ClusterManager # noqa
15+
from .controller.dependency import * # noqa
16+
from .error import * # noqa
17+
from .serialize import * # noqa
18+
from .util import interactive # noqa
2319

2420
# -----------------------------------------------------------------------------
2521
# Functions

ipyparallel/apps/baseapp.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
from IPython.core.application import base_flags as base_ip_flags
1212
from IPython.core.application import BaseIPythonApplication
1313
from IPython.utils.path import expand_path
14-
from IPython.utils.process import check_pid
15-
from ipython_genutils import py3compat
16-
from ipython_genutils.py3compat import unicode_type
1714
from jupyter_client.session import Session
1815
from tornado.ioloop import IOLoop
1916
from traitlets import Bool
@@ -87,12 +84,12 @@ def _log_format_default(self):
8784
return u"%(asctime)s.%(msecs).03d [%(name)s]%(highlevel)s %(message)s"
8885

8986
work_dir = Unicode(
90-
py3compat.getcwd(), config=True, help='Set the working dir for the process.'
87+
os.getcwd(), config=True, help='Set the working dir for the process.'
9188
)
9289

9390
@observe('work_dir')
9491
def _work_dir_changed(self, change):
95-
self.work_dir = unicode_type(expand_path(change['new']))
92+
self.work_dir = str(expand_path(change['new']))
9693

9794
log_to_file = Bool(config=True, help="whether to log to a file")
9895

@@ -170,7 +167,7 @@ def init_deprecated_config(self):
170167

171168
def to_work_dir(self):
172169
wd = self.work_dir
173-
if unicode_type(wd) != py3compat.getcwd():
170+
if wd != os.getcwd():
174171
os.chdir(wd)
175172
self.log.info("Changing to working dir: %s" % wd)
176173
# This is the working dir by now.

ipyparallel/apps/ipclusterapp.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
warnings.warn(f"{__name__} is deprecated in ipyparallel 7. Use ipyparallel.cluster")
44

5-
from ipyparallel.cluster.app import IPCluster, IPClusterStart, main
5+
from ipyparallel.cluster.app import IPCluster, IPClusterStart, main # noqa
66

77
IPClusterApp = IPCluster
88
launch_new_instance = main

0 commit comments

Comments
 (0)