diff --git a/benchmarks/bench_glm.py b/benchmarks/bench_glm.py
index 5bfc7f5629c18d59cb5cb6c9bf2b34a88f138de0..fed5e5bc106f867c9f5d64d05b2db264709436bc 100644
--- a/benchmarks/bench_glm.py
+++ b/benchmarks/bench_glm.py
@@ -20,13 +20,13 @@ if __name__ == '__main__':
     time_ols = np.empty(n_iter)
     time_lasso = np.empty(n_iter)
 
-    dimensions = 500 * np.arange(1, n_iter+1)
+    dimensions = 500 * np.arange(1, n_iter + 1)
 
     for i in range(n_iter):
 
         print 'Iteration %s of %s' % (i, n_iter)
 
-        n_samples, n_features = 10*i + 3, 10*i + 3
+        n_samples, n_features = 10 * i + 3, 10 * i + 3
 
         X = np.random.randn(n_samples, n_features)
         Y = np.random.randn(n_samples)
@@ -46,7 +46,6 @@ if __name__ == '__main__':
         lasso.fit(X, Y)
         time_lasso[i] = total_seconds(datetime.now() - start)
 
-
     pl.xlabel('Dimesions')
     pl.ylabel('Time (in seconds)')
     pl.plot(dimensions, time_ridge, color='r')
diff --git a/benchmarks/bench_glmnet.py b/benchmarks/bench_glmnet.py
index 2b866eb09b9cfd4e71b6e373ea7b270ce1193cb2..b9c77fbed06097fec5e1e69a9b3b89ed6a691d66 100644
--- a/benchmarks/bench_glmnet.py
+++ b/benchmarks/bench_glmnet.py
@@ -77,10 +77,10 @@ if __name__ == '__main__':
         glmnet_results.append(bench(GlmnetLasso, X, Y, X_test, Y_test, coef_))
 
     pl.clf()
-    xx = range(0, n*step, step)
+    xx = range(0, n * step, step)
     pl.title('Lasso regression on sample dataset (%d features)' % n_features)
     pl.plot(xx, scikit_results, 'b-', label='scikit-learn')
-    pl.plot(xx, glmnet_results,'r-', label='glmnet')
+    pl.plot(xx, glmnet_results, 'r-', label='glmnet')
     pl.legend()
     pl.xlabel('number of samples to classify')
     pl.ylabel('time (in seconds)')
@@ -120,10 +120,9 @@ if __name__ == '__main__':
     pl.figure()
     pl.title('Regression in high dimensional spaces (%d samples)' % n_samples)
     pl.plot(xx, scikit_results, 'b-', label='scikit-learn')
-    pl.plot(xx, glmnet_results,'r-', label='glmnet')
+    pl.plot(xx, glmnet_results, 'r-', label='glmnet')
     pl.legend()
     pl.xlabel('number of features')
     pl.ylabel('time (in seconds)')
     pl.axis('tight')
     pl.show()
-
diff --git a/benchmarks/bench_lasso.py b/benchmarks/bench_lasso.py
index b54e6bdeb1e239fdcc927aa82719cb91958644f0..5594e3e35035b1c2c0af81d8e15151ff4c4af158 100644
--- a/benchmarks/bench_lasso.py
+++ b/benchmarks/bench_lasso.py
@@ -38,7 +38,7 @@ def compute_bench(alpha, n_samples, n_features, precompute):
                                           n_informative=n_informative,
                                           noise=0.1, coef=True)
 
-            X /= np.sqrt(np.sum(X**2, axis=0)) # Normalize data
+            X /= np.sqrt(np.sum(X ** 2, axis=0))  # Normalize data
 
             gc.collect()
             print "- benching Lasso"
@@ -61,7 +61,7 @@ if __name__ == '__main__':
     from sklearn.linear_model import Lasso, LassoLars
     import pylab as pl
 
-    alpha = 0.01 # regularization parameter
+    alpha = 0.01  # regularization parameter
 
     n_features = 10
     list_n_samples = np.linspace(100, 1000000, 5).astype(np.int)
diff --git a/benchmarks/bench_plot_fastkmeans.py b/benchmarks/bench_plot_fastkmeans.py
index 5eff4b7fb3bcbdaef53c17974dc79ae7796bfffa..fea541f04e683ee0c7f0f511314c7964a646e4e0 100644
--- a/benchmarks/bench_plot_fastkmeans.py
+++ b/benchmarks/bench_plot_fastkmeans.py
@@ -20,7 +20,7 @@ def compute_bench(samples_range, features_range):
         for n_features in features_range:
             it += 1
             print '=============================='
-            print 'Iteration %03d of %03d' %(it, max_it)
+            print 'Iteration %03d of %03d' % (it, max_it)
             print '=============================='
             print ''
             data = nr.random_integers(-50, 50, (n_samples, n_features))
@@ -70,7 +70,7 @@ def compute_bench_2(chunks):
     for chunk in chunks:
         it += 1
         print '=============================='
-        print 'Iteration %03d of %03d' %(it, max_it)
+        print 'Iteration %03d of %03d' % (it, max_it)
         print '=============================='
         print ''
 
@@ -93,7 +93,7 @@ def compute_bench_2(chunks):
 
 
 if __name__ == '__main__':
-    from mpl_toolkits.mplot3d import axes3d # register the 3d projection
+    from mpl_toolkits.mplot3d import axes3d  # register the 3d projection
     import matplotlib.pyplot as plt
 
     samples_range = np.linspace(50, 150, 5).astype(np.int)
@@ -126,7 +126,6 @@ if __name__ == '__main__':
         ax.set_xlabel('n_samples')
         ax.set_ylabel('n_features')
 
-
     i = 0
     for c, (label, timings) in zip('br',
                                    sorted(results_2.iteritems())):
@@ -137,5 +136,4 @@ if __name__ == '__main__':
         ax.set_xlabel('chunks')
         ax.set_ylabel(label)
 
-
     plt.show()
diff --git a/benchmarks/bench_plot_lasso_path.py b/benchmarks/bench_plot_lasso_path.py
index 09dd7f084bc22b0495de9308a9fd8fa381c3c062..845368e9e8e2458564753625e046a5c97e474683 100644
--- a/benchmarks/bench_plot_lasso_path.py
+++ b/benchmarks/bench_plot_lasso_path.py
@@ -43,7 +43,7 @@ def compute_bench(samples_range, features_range):
             print "benching lars_path (with Gram):",
             sys.stdout.flush()
             tstart = time()
-            G = np.dot(X.T, X) # precomputed Gram matrix
+            G = np.dot(X.T, X)  # precomputed Gram matrix
             Xy = np.dot(X.T, y)
             lars_path(X, y, Xy=Xy, Gram=G, method='lasso')
             delta = time() - tstart
@@ -81,7 +81,7 @@ def compute_bench(samples_range, features_range):
 
 
 if __name__ == '__main__':
-    from mpl_toolkits.mplot3d import axes3d # register the 3d projection
+    from mpl_toolkits.mplot3d import axes3d  # register the 3d projection
     import matplotlib.pyplot as plt
 
     samples_range = np.linspace(10, 2000, 5).astype(np.int)
diff --git a/benchmarks/bench_plot_neighbors.py b/benchmarks/bench_plot_neighbors.py
index 1fd551a586b3fb201896ec6e5f12c92de14f61b6..3cfc9883997ecabbe2551af6a9553c478a1adf79 100644
--- a/benchmarks/bench_plot_neighbors.py
+++ b/benchmarks/bench_plot_neighbors.py
@@ -59,7 +59,6 @@ def barplot_neighbors(Nrange=2 ** np.arange(1, 11),
             N_results_build[algorithm][i] = (t1 - t0)
             N_results_query[algorithm][i] = (t2 - t1)
 
-
     #------------------------------------------------------------
     # varying D
     D_results_build = dict([(alg, np.zeros(len(Drange)))
@@ -83,7 +82,6 @@ def barplot_neighbors(Nrange=2 ** np.arange(1, 11),
             D_results_build[algorithm][i] = (t1 - t0)
             D_results_query[algorithm][i] = (t2 - t1)
 
-
     #------------------------------------------------------------
     # varying k
     k_results_build = dict([(alg, np.zeros(len(krange)))
diff --git a/benchmarks/bench_plot_omp_lars.py b/benchmarks/bench_plot_omp_lars.py
index 74479e426d405b4aaf09516731edf13c722eb012..7341c892911bc8fd0e2cf7fa22d0bf217cc1e8a6 100644
--- a/benchmarks/bench_plot_omp_lars.py
+++ b/benchmarks/bench_plot_omp_lars.py
@@ -108,7 +108,7 @@ if __name__ == '__main__':
     for i, (label, timings) in enumerate(sorted(results.iteritems())):
         ax = fig.add_subplot(1, 2, i)
         vmax = max(1 - timings.min(), -1 + timings.max())
-        pl.matshow(timings, fignum=False, vmin=1-vmax, vmax=1+vmax)
+        pl.matshow(timings, fignum=False, vmin=1 - vmax, vmax=1 + vmax)
         ax.set_xticklabels([''] + map(str, samples_range))
         ax.set_yticklabels([''] + map(str, features_range))
         pl.xlabel('n_samples')
diff --git a/benchmarks/bench_plot_svd.py b/benchmarks/bench_plot_svd.py
index 8a9ac7927c3fd243bce54f1c4a040500323ba7f5..6b24964ed3936e84a73cf8b0216ee2e5477ba532 100644
--- a/benchmarks/bench_plot_svd.py
+++ b/benchmarks/bench_plot_svd.py
@@ -25,7 +25,8 @@ def compute_bench(samples_range, features_range, q=3, rank=50):
             print '===================='
             print 'Iteration %03d of %03d' % (it, max_it)
             print '===================='
-            X = make_low_rank_matrix(n_samples, n_features, effective_rank=rank,
+            X = make_low_rank_matrix(n_samples, n_features,
+                                  effective_rank=rank,
                                   tail_strength=0.2)
 
             gc.collect()
@@ -50,7 +51,7 @@ def compute_bench(samples_range, features_range, q=3, rank=50):
 
 
 if __name__ == '__main__':
-    from mpl_toolkits.mplot3d import axes3d # register the 3d projection
+    from mpl_toolkits.mplot3d import axes3d  # register the 3d projection
     import matplotlib.pyplot as plt
 
     samples_range = np.linspace(2, 1000, 4).astype(np.int)
diff --git a/benchmarks/bench_plot_ward.py b/benchmarks/bench_plot_ward.py
index f6e32673d259d1689829dc64ee33e547755fe2c8..6f8f4494d072f17385ad25f18782ba0d7b887df6 100644
--- a/benchmarks/bench_plot_ward.py
+++ b/benchmarks/bench_plot_ward.py
@@ -29,7 +29,7 @@ for i, n in enumerate(n_samples):
         hierarchy.ward(X)
         scipy_time[j, i] = time.time() - t0
 
-ratio = scikits_time/scipy_time
+ratio = scikits_time / scipy_time
 
 pl.clf()
 pl.imshow(np.log(ratio), aspect='auto', origin="lower")
diff --git a/benchmarks/bench_sgd_covertype.py b/benchmarks/bench_sgd_covertype.py
index 9a8b7993a3940e2e8fbba9bd75045482a59217cb..f7a501ab5a02634aefcb1d01d7346bfb380d2531 100644
--- a/benchmarks/bench_sgd_covertype.py
+++ b/benchmarks/bench_sgd_covertype.py
@@ -4,12 +4,12 @@ Covertype dataset with dense SGD
 ================================
 
 Benchmark stochastic gradient descent (SGD), Liblinear, and Naive Bayes, CART
-(decision tree), RandomForest and Extra-Trees on the forest covertype dataset of
-Blackard, Jock, and Dean [1]. The dataset comprises 581,012 samples. It is low-
-dimensional with 54 features and a sparsity of approx. 23%. Here, we consider
-the task of predicting class 1 (spruce/fir). The classification performance of
-SGD is competitive with Liblinear while being two orders of magnitude faster to
-train::
+(decision tree), RandomForest and Extra-Trees on the forest covertype dataset
+of Blackard, Jock, and Dean [1]. The dataset comprises 581,012 samples. It is
+low dimensional with 54 features and a sparsity of approx. 23%. Here, we
+consider the task of predicting class 1 (spruce/fir). The classification
+performance of SGD is competitive with Liblinear while being two orders of
+magnitude faster to train::
 
     [..]
     Classification performance:
diff --git a/doc/conf.py b/doc/conf.py
index 0d97bc65bb797cadb11b64e9aec20f0194f09307..ac78d66cc3f2b37f230140a1168d0905aba29313 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -3,7 +3,8 @@
 # scikit-learn documentation build configuration file, created by
 # sphinx-quickstart on Fri Jan  8 09:13:42 2010.
 #
-# This file is execfile()d with the current directory set to its containing dir.
+# This file is execfile()d with the current directory set to its containing
+# dir.
 #
 # Note that not all possible configuration values are present in this
 # autogenerated file.
@@ -11,14 +12,16 @@
 # All configuration values have a default; values that are commented out
 # serve to show the default.
 
-import sys, os
+import sys
+import os
 
-# If extensions (or modules to document with autodoc) are in another directory,
-# add these directories to sys.path here. If the directory is relative to the
-# documentation root, use os.path.abspath to make it absolute, like shown here.
+# If extensions (or modules to document with autodoc) are in another
+# directory, add these directories to sys.path here. If the directory
+# is relative to the documentation root, use os.path.abspath to make it
+# absolute, like shown here.
 sys.path.insert(0, os.path.abspath('sphinxext'))
 
-# -- General configuration -----------------------------------------------------
+# -- General configuration ---------------------------------------------------
 
 # Try to override the matplotlib configuration as early as possible
 try:
@@ -26,8 +29,8 @@ try:
 except:
     pass
 
-# Add any Sphinx extension module names here, as strings. They can be extensions
-# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
+# Add any Sphinx extension module names here, as strings. They can be
+# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
 extensions = ['gen_rst',
               'sphinx.ext.autodoc', 'sphinx.ext.autosummary',
               'sphinx.ext.pngmath',
@@ -36,7 +39,7 @@ try:
     import numpy_ext.numpydoc
     extensions.append('numpy_ext.numpydoc')
     # With older versions of sphinx, this causes a crash
-    autosummary_generate=True
+    autosummary_generate = True
 except:
     # Older version of sphinx
     extensions.append('numpy_ext_old.numpydoc')
@@ -88,11 +91,12 @@ release = sklearn.__version__
 # List of documents that shouldn't be included in the build.
 #unused_docs = []
 
-# List of directories, relative to source directory, that shouldn't be searched
-# for source files.
+# List of directories, relative to source directory, that shouldn't be
+# searched for source files.
 exclude_trees = ['_build', 'templates', 'includes']
 
-# The reST default role (used for this markup: `text`) to use for all documents.
+# The reST default role (used for this markup: `text`) to use for all
+# documents.
 #default_role = None
 
 # If true, '()' will be appended to :func: etc. cross-reference text.
@@ -113,7 +117,7 @@ pygments_style = 'sphinx'
 #modindex_common_prefix = []
 
 
-# -- Options for HTML output ---------------------------------------------------
+# -- Options for HTML output -------------------------------------------------
 
 # The theme to use for HTML and HTML Help pages.  Major themes that come with
 # Sphinx are currently 'default' and 'sphinxdoc'.
@@ -187,7 +191,7 @@ html_use_index = False
 htmlhelp_basename = 'scikit-learndoc'
 
 
-# -- Options for LaTeX output --------------------------------------------------
+# -- Options for LaTeX output ------------------------------------------------
 
 # The paper size ('letter' or 'a4').
 #latex_paper_size = 'letter'
@@ -196,7 +200,8 @@ htmlhelp_basename = 'scikit-learndoc'
 #latex_font_size = '10pt'
 
 # Grouping the document tree into LaTeX files. List of tuples
-# (source start file, target name, title, author, documentclass [howto/manual]).
+# (source start file, target name, title, author, documentclass
+# [howto/manual]).
 latex_documents = [
   ('index', 'user_guide.tex', u'scikit-learn user guide',
    u'scikit-learn developers', 'manual'),
diff --git a/doc/datasets/mldata_fixture.py b/doc/datasets/mldata_fixture.py
index 2267288c38fb54542211d1b5c038548650e1c9f9..056719701a9b2c2c70aec2b94692306ebbbe1cce 100644
--- a/doc/datasets/mldata_fixture.py
+++ b/doc/datasets/mldata_fixture.py
@@ -12,7 +12,6 @@ import scipy as sp
 import shutil
 
 
-
 def globs(globs):
     # setup mock urllib2 module to avoid downloading from mldata.org
     mock_datasets = {
diff --git a/doc/sphinxext/gen_rst.py b/doc/sphinxext/gen_rst.py
index 7fef2835730b519b28787e6259b6e66469d7622f..ba703a60b2edb89aa31d66ae0a63ebadc367cbf8 100644
--- a/doc/sphinxext/gen_rst.py
+++ b/doc/sphinxext/gen_rst.py
@@ -17,7 +17,8 @@ from StringIO import StringIO
 import matplotlib
 matplotlib.use('Agg')
 
-import token, tokenize
+import token
+import tokenize
 
 rst_template = """
 
@@ -67,6 +68,7 @@ SINGLE_IMAGE = """
     :align: center
 """
 
+
 def extract_docstring(filename):
     """ Extract a module-level docstring, if any
     """
@@ -88,11 +90,11 @@ def extract_docstring(filename):
             # If the docstring is formatted with several paragraphs, extract
             # the first one:
             paragraphs = '\n'.join(line.rstrip()
-                                for line in docstring.split('\n')).split('\n\n')
+                              for line in docstring.split('\n')).split('\n\n')
             if len(paragraphs) > 0:
                 first_par = paragraphs[0]
         break
-    return docstring, first_par, erow+1+start_row
+    return docstring, first_par, erow + 1 + start_row
 
 
 def generate_example_rst(app):
@@ -100,7 +102,7 @@ def generate_example_rst(app):
         examples.
     """
     root_dir = os.path.join(app.builder.srcdir, 'auto_examples')
-    example_dir = os.path.abspath(app.builder.srcdir +  '/../' + 'examples')
+    example_dir = os.path.abspath(app.builder.srcdir + '/../' + 'examples')
     try:
         plot_gallery = eval(app.builder.config.plot_gallery)
     except TypeError:
@@ -159,11 +161,11 @@ def generate_dir_rst(dir, fhindex, example_dir, root_dir, plot_gallery):
         target_dir = root_dir
         src_dir = example_dir
     if not os.path.exists(os.path.join(src_dir, 'README.txt')):
-        print 80*'_'
+        print 80 * '_'
         print ('Example directory %s does not have a README.txt file'
                         % src_dir)
         print 'Skipping this directory'
-        print 80*'_'
+        print 80 * '_'
         return
     fhindex.write("""
 
@@ -189,7 +191,8 @@ def generate_dir_rst(dir, fhindex, example_dir, root_dir, plot_gallery):
             if link_name.startswith('._'):
                 link_name = link_name[2:]
             if dir != '.':
-                fhindex.write('   :target: ./%s/%s.html\n\n' % (dir, fname[:-3]))
+                fhindex.write('   :target: ./%s/%s.html\n\n' % (dir,
+                                                               fname[:-3]))
             else:
                 fhindex.write('   :target: ./%s.html\n\n' % link_name[:-3])
             fhindex.write("""   :ref:`example_%s`
@@ -204,7 +207,7 @@ def generate_dir_rst(dir, fhindex, example_dir, root_dir, plot_gallery):
 .. raw:: html
 
     <div style="clear: both"></div>
-    """) # clear at the end of the section
+    """)  # clear at the end of the section
 
 
 def generate_file_rst(fname, target_dir, src_dir, plot_gallery):
@@ -257,13 +260,13 @@ def generate_file_rst(fname, target_dir, src_dir, plot_gallery):
             plt.close('all')
             cwd = os.getcwd()
             try:
-                # First CD in the original example dir, so that any file created
-                # by the example get created in this directory
+                # First CD in the original example dir, so that any file
+                # created by the example get created in this directory
                 orig_stdout = sys.stdout
                 os.chdir(os.path.dirname(src_file))
                 my_stdout = StringIO()
                 sys.stdout = my_stdout
-                my_globals = {'pl' : plt}
+                my_globals = {'pl': plt}
                 execfile(os.path.basename(src_file), my_globals)
                 sys.stdout = orig_stdout
                 my_stdout = my_stdout.getvalue()
@@ -287,17 +290,17 @@ def generate_file_rst(fname, target_dir, src_dir, plot_gallery):
                 # * iterate over [fig_mngr.num for fig_mngr in
                 #   matplotlib._pylab_helpers.Gcf.get_all_fig_managers()]
                 for fig_num in (fig_mngr.num for fig_mngr in
-                          matplotlib._pylab_helpers.Gcf.get_all_fig_managers()):
+                        matplotlib._pylab_helpers.Gcf.get_all_fig_managers()):
                     # Set the fig_num figure as the current figure as we can't
                     # save a figure that's not the current figure.
                     plt.figure(fig_num)
                     plt.savefig(image_path % fig_num)
                     figure_list.append(image_fname % fig_num)
             except:
-                print 80*'_'
+                print 80 * '_'
                 print '%s is not compiling:' % fname
                 traceback.print_exc()
-                print 80*'_'
+                print 80 * '_'
             finally:
                 os.chdir(cwd)
                 sys.stdout = orig_stdout
@@ -328,7 +331,7 @@ def generate_file_rst(fname, target_dir, src_dir, plot_gallery):
         for figure_name in figure_list:
             image_list += HLIST_IMAGE_TEMPLATE % figure_name.lstrip('/')
 
-    f = open(os.path.join(target_dir, fname[:-2] + 'rst'),'w')
+    f = open(os.path.join(target_dir, fname[:-2] + 'rst'), 'w')
     f.write(this_template % locals())
     f.flush()
 
diff --git a/doc/sphinxext/numpy_ext/docscrape.py b/doc/sphinxext/numpy_ext/docscrape.py
index 6be4d3b0f1d8ac7e7c274011a61ba8dd35faf0f3..e9670c05f5a6338e19f61860c290efffa180c13a 100644
--- a/doc/sphinxext/numpy_ext/docscrape.py
+++ b/doc/sphinxext/numpy_ext/docscrape.py
@@ -9,6 +9,7 @@ import pydoc
 from StringIO import StringIO
 from warnings import warn
 
+
 class Reader(object):
     """A line-based string reader.
 
@@ -21,10 +22,10 @@ class Reader(object):
            String with lines separated by '\n'.
 
         """
-        if isinstance(data,list):
+        if isinstance(data, list):
             self._str = data
         else:
-            self._str = data.split('\n') # store string as list of lines
+            self._str = data.split('\n')  # store string as list of lines
 
         self.reset()
 
@@ -32,7 +33,7 @@ class Reader(object):
         return self._str[n]
 
     def reset(self):
-        self._l = 0 # current line nr
+        self._l = 0  # current line nr
 
     def read(self):
         if not self.eof():
@@ -59,11 +60,12 @@ class Reader(object):
                 return self[start:self._l]
             self._l += 1
             if self.eof():
-                return self[start:self._l+1]
+                return self[start:self._l + 1]
         return []
 
     def read_to_next_empty_line(self):
         self.seek_next_non_empty_line()
+
         def is_empty(line):
             return not line.strip()
         return self.read_to_condition(is_empty)
@@ -73,7 +75,7 @@ class Reader(object):
             return (line.strip() and (len(line.lstrip()) == len(line)))
         return self.read_to_condition(is_unindented)
 
-    def peek(self,n=0):
+    def peek(self, n=0):
         if self._l + n < len(self._str):
             return self[self._l + n]
         else:
@@ -109,10 +111,10 @@ class NumpyDocString(object):
 
         self._parse()
 
-    def __getitem__(self,key):
+    def __getitem__(self, key):
         return self._parsed_data[key]
 
-    def __setitem__(self,key,val):
+    def __setitem__(self, key, val):
         if not self._parsed_data.has_key(key):
             warn("Unknown section %s" % key)
         else:
@@ -129,25 +131,27 @@ class NumpyDocString(object):
         if l1.startswith('.. index::'):
             return True
 
-        l2 = self._doc.peek(1).strip() #    ---------- or ==========
-        return l2.startswith('-'*len(l1)) or l2.startswith('='*len(l1))
+        l2 = self._doc.peek(1).strip()   # ---------- or ==========
+        return l2.startswith('-' * len(l1)) or l2.startswith('=' * len(l1))
 
-    def _strip(self,doc):
+    def _strip(self, doc):
         i = 0
         j = 0
-        for i,line in enumerate(doc):
-            if line.strip(): break
+        for i, line in enumerate(doc):
+            if line.strip():
+                break
 
-        for j,line in enumerate(doc[::-1]):
-            if line.strip(): break
+        for j, line in enumerate(doc[::-1]):
+            if line.strip():
+                break
 
-        return doc[i:len(doc)-j]
+        return doc[i:len(doc) - j]
 
     def _read_to_next_section(self):
         section = self._doc.read_to_next_empty_line()
 
         while not self._is_at_section() and not self._doc.eof():
-            if not self._doc.peek(-1).strip(): # previous line was empty
+            if not self._doc.peek(-1).strip():  # previous line was empty
                 section += ['']
 
             section += self._doc.read_to_next_empty_line()
@@ -159,14 +163,14 @@ class NumpyDocString(object):
             data = self._read_to_next_section()
             name = data[0].strip()
 
-            if name.startswith('..'): # index section
+            if name.startswith('..'):  # index section
                 yield name, data[1:]
             elif len(data) < 2:
                 yield StopIteration
             else:
                 yield name, self._strip(data[2:])
 
-    def _parse_param_list(self,content):
+    def _parse_param_list(self, content):
         r = Reader(content)
         params = []
         while not r.eof():
@@ -179,13 +183,13 @@ class NumpyDocString(object):
             desc = r.read_to_next_unindented_line()
             desc = dedent_lines(desc)
 
-            params.append((arg_name,arg_type,desc))
+            params.append((arg_name, arg_type, desc))
 
         return params
 
-
     _name_rgx = re.compile(r"^\s*(:(?P<role>\w+):`(?P<name>[a-zA-Z0-9_.-]+)`|"
                            r" (?P<name2>[a-zA-Z0-9_.-]+))\s*", re.X)
+
     def _parse_see_also(self, content):
         """
         func_name : Descriptive text
@@ -218,7 +222,8 @@ class NumpyDocString(object):
         rest = []
 
         for line in content:
-            if not line.strip(): continue
+            if not line.strip():
+                continue
 
             m = self._name_rgx.match(line)
             if m and line[m.end():].strip().startswith(':'):
@@ -280,9 +285,10 @@ class NumpyDocString(object):
         self._doc.reset()
         self._parse_summary()
 
-        for (section,content) in self._read_sections():
+        for (section, content) in self._read_sections():
             if not section.startswith('..'):
-                section = ' '.join([s.capitalize() for s in section.split(' ')])
+                section = ' '.join([s.capitalize()
+                                    for s in section.split(' ')])
             if section in ('Parameters', 'Attributes', 'Methods',
                            'Returns', 'Raises', 'Warns'):
                 self[section] = self._parse_param_list(content)
@@ -296,17 +302,17 @@ class NumpyDocString(object):
     # string conversion routines
 
     def _str_header(self, name, symbol='-'):
-        return [name, len(name)*symbol]
+        return [name, len(name) * symbol]
 
     def _str_indent(self, doc, indent=4):
         out = []
         for line in doc:
-            out += [' '*indent + line]
+            out += [' ' * indent + line]
         return out
 
     def _str_signature(self):
         if self['Signature']:
-            return [self['Signature'].replace('*','\*')] + ['']
+            return [self['Signature'].replace('*', '\*')] + ['']
         else:
             return ['']
 
@@ -326,7 +332,7 @@ class NumpyDocString(object):
         out = []
         if self[name]:
             out += self._str_header(name)
-            for param,param_type,desc in self[name]:
+            for param, param_type, desc in self[name]:
                 out += ['%s : %s' % (param, param_type)]
                 out += self._str_indent(desc)
             out += ['']
@@ -341,7 +347,8 @@ class NumpyDocString(object):
         return out
 
     def _str_see_also(self, func_role):
-        if not self['See Also']: return []
+        if not self['See Also']:
+            return []
         out = []
         out += self._str_header("See Also")
         last_had_desc = True
@@ -368,7 +375,7 @@ class NumpyDocString(object):
     def _str_index(self):
         idx = self['index']
         out = []
-        out += ['.. index:: %s' % idx.get('default','')]
+        out += ['.. index:: %s' % idx.get('default', '')]
         for section, references in idx.iteritems():
             if section == 'default':
                 continue
@@ -380,11 +387,11 @@ class NumpyDocString(object):
         out += self._str_signature()
         out += self._str_summary()
         out += self._str_extended_summary()
-        for param_list in ('Parameters','Returns','Raises'):
+        for param_list in ('Parameters', 'Returns', 'Raises'):
             out += self._str_param_list(param_list)
         out += self._str_section('Warnings')
         out += self._str_see_also(func_role)
-        for s in ('Notes','References','Examples'):
+        for s in ('Notes', 'References', 'Examples'):
             out += self._str_section(s)
         for param_list in ('Attributes', 'Methods'):
             out += self._str_param_list(param_list)
@@ -392,25 +399,27 @@ class NumpyDocString(object):
         return '\n'.join(out)
 
 
-def indent(str,indent=4):
-    indent_str = ' '*indent
+def indent(str, indent=4):
+    indent_str = ' ' * indent
     if str is None:
         return indent_str
     lines = str.split('\n')
     return '\n'.join(indent_str + l for l in lines)
 
+
 def dedent_lines(lines):
     """Deindent a list of lines maximally"""
     return textwrap.dedent("\n".join(lines)).split("\n")
 
+
 def header(text, style='-'):
-    return text + '\n' + style*len(text) + '\n'
+    return text + '\n' + style * len(text) + '\n'
 
 
 class FunctionDoc(NumpyDocString):
     def __init__(self, func, role='func', doc=None, config={}):
         self._f = func
-        self._role = role # e.g. "func" or "meth"
+        self._role = role  # e.g. "func" or "meth"
 
         if doc is None:
             if func is None:
@@ -424,7 +433,7 @@ class FunctionDoc(NumpyDocString):
                 # try to read signature
                 argspec = inspect.getargspec(func)
                 argspec = inspect.formatargspec(*argspec)
-                argspec = argspec.replace('*','\*')
+                argspec = argspec.replace('*', '\*')
                 signature = '%s%s' % (func_name, argspec)
             except TypeError, e:
                 signature = '%s()' % func_name
@@ -450,7 +459,7 @@ class FunctionDoc(NumpyDocString):
         if self._role:
             if not roles.has_key(self._role):
                 print "Warning: invalid role %s" % self._role
-            out += '.. %s:: %s\n    \n\n' % (roles.get(self._role,''),
+            out += '.. %s:: %s\n    \n\n' % (roles.get(self._role, ''),
                                              func_name)
 
         out += super(FunctionDoc, self).__str__(func_role=self._role)
@@ -487,12 +496,12 @@ class ClassDoc(NumpyDocString):
     def methods(self):
         if self._cls is None:
             return []
-        return [name for name,func in inspect.getmembers(self._cls)
+        return [name for name, func in inspect.getmembers(self._cls)
                 if not name.startswith('_') and callable(func)]
 
     @property
     def properties(self):
         if self._cls is None:
             return []
-        return [name for name,func in inspect.getmembers(self._cls)
+        return [name for name, func in inspect.getmembers(self._cls)
                 if not name.startswith('_') and func is None]
diff --git a/doc/sphinxext/numpy_ext/docscrape_sphinx.py b/doc/sphinxext/numpy_ext/docscrape_sphinx.py
index 7a575c1b6396e025f2e4c4c8021387fcae0f5b1d..bcf7e70731cc798b73e4f22a48c25d361f65c6d1 100644
--- a/doc/sphinxext/numpy_ext/docscrape_sphinx.py
+++ b/doc/sphinxext/numpy_ext/docscrape_sphinx.py
@@ -1,6 +1,12 @@
-import re, inspect, textwrap, pydoc
+import re
+import inspect
+import textwrap
+import pydoc
 import sphinx
-from docscrape import NumpyDocString, FunctionDoc, ClassDoc
+from docscrape import NumpyDocString
+from docscrape import FunctionDoc
+from docscrape import ClassDoc
+
 
 class SphinxDocString(NumpyDocString):
     def __init__(self, docstring, config=None):
@@ -18,7 +24,7 @@ class SphinxDocString(NumpyDocString):
     def _str_indent(self, doc, indent=4):
         out = []
         for line in doc:
-            out += [' '*indent + line]
+            out += [' ' * indent + line]
         return out
 
     def _str_signature(self):
@@ -39,11 +45,11 @@ class SphinxDocString(NumpyDocString):
         if self[name]:
             out += self._str_field_list(name)
             out += ['']
-            for param,param_type,desc in self[name]:
+            for param, param_type, desc in self[name]:
                 out += self._str_indent(['**%s** : %s' % (param.strip(),
                                                           param_type)])
                 out += ['']
-                out += self._str_indent(desc,8)
+                out += self._str_indent(desc, 8)
                 out += ['']
         return out
 
@@ -88,7 +94,7 @@ class SphinxDocString(NumpyDocString):
             if others:
                 maxlen_0 = max([len(x[0]) for x in others])
                 maxlen_1 = max([len(x[1]) for x in others])
-                hdr = "="*maxlen_0 + "  " + "="*maxlen_1 + "  " + "="*10
+                hdr = "=" * maxlen_0 + "  " + "=" * maxlen_1 + "  " + "=" * 10
                 fmt = '%%%ds  %%%ds  ' % (maxlen_0, maxlen_1)
                 n_indent = maxlen_0 + maxlen_1 + 4
                 out += [hdr]
@@ -130,7 +136,7 @@ class SphinxDocString(NumpyDocString):
         if len(idx) == 0:
             return out
 
-        out += ['.. index:: %s' % idx.get('default','')]
+        out += ['.. index:: %s' % idx.get('default', '')]
         for section, references in idx.iteritems():
             if section == 'default':
                 continue
@@ -151,9 +157,9 @@ class SphinxDocString(NumpyDocString):
             # Latex collects all references to a separate bibliography,
             # so we need to insert links to it
             if sphinx.__version__ >= "0.6":
-                out += ['.. only:: latex','']
+                out += ['.. only:: latex', '']
             else:
-                out += ['.. latexonly::','']
+                out += ['.. latexonly::', '']
             items = []
             for line in self['References']:
                 m = re.match(r'.. \[([a-z0-9._-]+)\]', line, re.I)
@@ -191,24 +197,28 @@ class SphinxDocString(NumpyDocString):
         out += self._str_examples()
         for param_list in ('Attributes', 'Methods'):
             out += self._str_member_list(param_list)
-        out = self._str_indent(out,indent)
+        out = self._str_indent(out, indent)
         return '\n'.join(out)
 
+
 class SphinxFunctionDoc(SphinxDocString, FunctionDoc):
     def __init__(self, obj, doc=None, config={}):
         self.use_plots = config.get('use_plots', False)
         FunctionDoc.__init__(self, obj, doc=doc, config=config)
 
+
 class SphinxClassDoc(SphinxDocString, ClassDoc):
     def __init__(self, obj, doc=None, func_doc=None, config={}):
         self.use_plots = config.get('use_plots', False)
         ClassDoc.__init__(self, obj, doc=doc, func_doc=None, config=config)
 
+
 class SphinxObjDoc(SphinxDocString):
     def __init__(self, obj, doc=None, config=None):
         self._f = obj
         SphinxDocString.__init__(self, doc, config=config)
 
+
 def get_doc_object(obj, what=None, doc=None, config={}):
     if what is None:
         if inspect.isclass(obj):
diff --git a/doc/sphinxext/numpy_ext/numpydoc.py b/doc/sphinxext/numpy_ext/numpydoc.py
index aa390056b3ad394aba760d497fb81741cd73a4e6..62adb56ae74897d2bc75a91a7382322a99c30d8e 100644
--- a/doc/sphinxext/numpy_ext/numpydoc.py
+++ b/doc/sphinxext/numpy_ext/numpydoc.py
@@ -10,17 +10,22 @@ It will:
 - Convert Parameters etc. sections to field lists.
 - Convert See Also section to a See also entry.
 - Renumber references.
-- Extract the signature from the docstring, if it can't be determined otherwise.
+- Extract the signature from the docstring, if it can't be determined
+  otherwise.
 
 .. [1] http://projects.scipy.org/numpy/wiki/CodingStyleGuidelines#docstring-standard
 
 """
 
-import os, re, pydoc
-from docscrape_sphinx import get_doc_object, SphinxDocString
+import os
+import re
+import pydoc
+from docscrape_sphinx import get_doc_object
+from docscrape_sphinx import SphinxDocString
 from sphinx.util.compat import Directive
 import inspect
 
+
 def mangle_docstrings(app, what, name, obj, options, lines,
                       reference_offset=[0]):
 
@@ -30,7 +35,7 @@ def mangle_docstrings(app, what, name, obj, options, lines,
     if what == 'module':
         # Strip top title
         title_re = re.compile(ur'^\s*[#*=]{4,}\n[a-z0-9 -]+\n[#*=]{4,}\s*',
-                              re.I|re.S)
+                              re.I | re.S)
         lines[:] = title_re.sub(u'', u"\n".join(lines)).split(u"\n")
     else:
         doc = get_doc_object(obj, what, u"\n".join(lines), config=cfg)
@@ -70,21 +75,26 @@ def mangle_docstrings(app, what, name, obj, options, lines,
 
     reference_offset[0] += len(references)
 
-def mangle_signature(app, what, name, obj, options, sig, retann):
+
+def mangle_signature(app, what, name, obj,
+                     options, sig, retann):
     # Do not try to inspect classes that don't define `__init__`
     if (inspect.isclass(obj) and
         (not hasattr(obj, '__init__') or
         'initializes x; see ' in pydoc.getdoc(obj.__init__))):
         return '', ''
 
-    if not (callable(obj) or hasattr(obj, '__argspec_is_invalid_')): return
-    if not hasattr(obj, '__doc__'): return
+    if not (callable(obj) or hasattr(obj, '__argspec_is_invalid_')):
+        return
+    if not hasattr(obj, '__doc__'):
+        return
 
     doc = SphinxDocString(pydoc.getdoc(obj))
     if doc['Signature']:
         sig = re.sub(u"^[^(]*", u"", doc['Signature'])
         return sig, u''
 
+
 def setup(app, get_doc_object_=get_doc_object):
     global get_doc_object
     get_doc_object = get_doc_object_
@@ -99,14 +109,15 @@ def setup(app, get_doc_object_=get_doc_object):
     app.add_domain(NumpyPythonDomain)
     app.add_domain(NumpyCDomain)
 
-#------------------------------------------------------------------------------
+#-----------------------------------------------------------------------------
 # Docstring-mangling domains
-#------------------------------------------------------------------------------
+#-----------------------------------------------------------------------------
 
 from docutils.statemachine import ViewList
 from sphinx.domains.c import CDomain
 from sphinx.domains.python import PythonDomain
 
+
 class ManglingDomainBase(object):
     directive_mangling_map = {}
 
@@ -119,6 +130,7 @@ class ManglingDomainBase(object):
             self.directives[name] = wrap_mangling_directive(
                 self.directives[name], objtype)
 
+
 class NumpyPythonDomain(ManglingDomainBase, PythonDomain):
     name = 'np'
     directive_mangling_map = {
@@ -131,6 +143,7 @@ class NumpyPythonDomain(ManglingDomainBase, PythonDomain):
         'attribute': 'attribute',
     }
 
+
 class NumpyCDomain(ManglingDomainBase, CDomain):
     name = 'np-c'
     directive_mangling_map = {
@@ -141,6 +154,7 @@ class NumpyCDomain(ManglingDomainBase, CDomain):
         'var': 'object',
     }
 
+
 def wrap_mangling_directive(base_directive, objtype):
     class directive(base_directive):
         def run(self):
@@ -161,4 +175,3 @@ def wrap_mangling_directive(base_directive, objtype):
             return base_directive.run(self)
 
     return directive
-
diff --git a/doc/sphinxext/numpy_ext_old/docscrape.py b/doc/sphinxext/numpy_ext_old/docscrape.py
index a4b7c21bc88280f43252a5cf286f3ce7da77d920..5eecdde36d79d151f79f739bc5c8a7e71bb2b150 100644
--- a/doc/sphinxext/numpy_ext_old/docscrape.py
+++ b/doc/sphinxext/numpy_ext_old/docscrape.py
@@ -8,7 +8,8 @@ import re
 import pydoc
 from StringIO import StringIO
 from warnings import warn
-4
+
+
 class Reader(object):
     """A line-based string reader.
 
@@ -21,10 +22,10 @@ class Reader(object):
            String with lines separated by '\n'.
 
         """
-        if isinstance(data,list):
+        if isinstance(data, list):
             self._str = data
         else:
-            self._str = data.split('\n') # store string as list of lines
+            self._str = data.split('\n')  # store string as list of lines
 
         self.reset()
 
@@ -32,7 +33,7 @@ class Reader(object):
         return self._str[n]
 
     def reset(self):
-        self._l = 0 # current line nr
+        self._l = 0  # current line nr
 
     def read(self):
         if not self.eof():
@@ -59,11 +60,12 @@ class Reader(object):
                 return self[start:self._l]
             self._l += 1
             if self.eof():
-                return self[start:self._l+1]
+                return self[start: self._l + 1]
         return []
 
     def read_to_next_empty_line(self):
         self.seek_next_non_empty_line()
+
         def is_empty(line):
             return not line.strip()
         return self.read_to_condition(is_empty)
@@ -73,7 +75,7 @@ class Reader(object):
             return (line.strip() and (len(line.lstrip()) == len(line)))
         return self.read_to_condition(is_unindented)
 
-    def peek(self,n=0):
+    def peek(self, n=0):
         if self._l + n < len(self._str):
             return self[self._l + n]
         else:
@@ -84,7 +86,7 @@ class Reader(object):
 
 
 class NumpyDocString(object):
-    def __init__(self,docstring):
+    def __init__(self, docstring):
         docstring = textwrap.dedent(docstring).split('\n')
 
         self._doc = Reader(docstring)
@@ -109,10 +111,10 @@ class NumpyDocString(object):
 
         self._parse()
 
-    def __getitem__(self,key):
+    def __getitem__(self, key):
         return self._parsed_data[key]
 
-    def __setitem__(self,key,val):
+    def __setitem__(self, key, val):
         if not self._parsed_data.has_key(key):
             warn("Unknown section %s" % key)
         else:
@@ -129,25 +131,27 @@ class NumpyDocString(object):
         if l1.startswith('.. index::'):
             return True
 
-        l2 = self._doc.peek(1).strip() #    ---------- or ==========
-        return l2.startswith('-'*len(l1)) or l2.startswith('='*len(l1))
+        l2 = self._doc.peek(1).strip()  # ---------- or ==========
+        return l2.startswith('-' * len(l1)) or l2.startswith('=' * len(l1))
 
-    def _strip(self,doc):
+    def _strip(self, doc):
         i = 0
         j = 0
-        for i,line in enumerate(doc):
-            if line.strip(): break
+        for i, line in enumerate(doc):
+            if line.strip():
+                break
 
-        for j,line in enumerate(doc[::-1]):
-            if line.strip(): break
+        for j, line in enumerate(doc[::-1]):
+            if line.strip():
+                break
 
-        return doc[i:len(doc)-j]
+        return doc[i: len(doc) - j]
 
     def _read_to_next_section(self):
         section = self._doc.read_to_next_empty_line()
 
         while not self._is_at_section() and not self._doc.eof():
-            if not self._doc.peek(-1).strip(): # previous line was empty
+            if not self._doc.peek(-1).strip():  # previous line was empty
                 section += ['']
 
             section += self._doc.read_to_next_empty_line()
@@ -159,14 +163,14 @@ class NumpyDocString(object):
             data = self._read_to_next_section()
             name = data[0].strip()
 
-            if name.startswith('..'): # index section
+            if name.startswith('..'):  # index section
                 yield name, data[1:]
             elif len(data) < 2:
                 yield StopIteration
             else:
                 yield name, self._strip(data[2:])
 
-    def _parse_param_list(self,content):
+    def _parse_param_list(self, content):
         r = Reader(content)
         params = []
         while not r.eof():
@@ -179,13 +183,13 @@ class NumpyDocString(object):
             desc = r.read_to_next_unindented_line()
             desc = dedent_lines(desc)
 
-            params.append((arg_name,arg_type,desc))
+            params.append((arg_name, arg_type, desc))
 
         return params
 
-
     _name_rgx = re.compile(r"^\s*(:(?P<role>\w+):`(?P<name>[a-zA-Z0-9_.-]+)`|"
                            r" (?P<name2>[a-zA-Z0-9_.-]+))\s*", re.X)
+
     def _parse_see_also(self, content):
         """
         func_name : Descriptive text
@@ -218,7 +222,8 @@ class NumpyDocString(object):
         rest = []
 
         for line in content:
-            if not line.strip(): continue
+            if not line.strip():
+                continue
 
             m = self._name_rgx.match(line)
             if m and line[m.end():].strip().startswith(':'):
@@ -280,7 +285,7 @@ class NumpyDocString(object):
         self._doc.reset()
         self._parse_summary()
 
-        for (section,content) in self._read_sections():
+        for (section, content) in self._read_sections():
             if not section.startswith('..'):
                 section = ' '.join([s.capitalize() for s in section.split(' ')])
             if section in ('Parameters', 'Attributes', 'Methods',
@@ -296,17 +301,17 @@ class NumpyDocString(object):
     # string conversion routines
 
     def _str_header(self, name, symbol='-'):
-        return [name, len(name)*symbol]
+        return [name, len(name) * symbol]
 
     def _str_indent(self, doc, indent=4):
         out = []
         for line in doc:
-            out += [' '*indent + line]
+            out += [' ' * indent + line]
         return out
 
     def _str_signature(self):
         if self['Signature']:
-            return [self['Signature'].replace('*','\*')] + ['']
+            return [self['Signature'].replace('*', '\*')] + ['']
         else:
             return ['']
 
@@ -326,7 +331,7 @@ class NumpyDocString(object):
         out = []
         if self[name]:
             out += self._str_header(name)
-            for param,param_type,desc in self[name]:
+            for param, param_type, desc in self[name]:
                 out += ['%s : %s' % (param, param_type)]
                 out += self._str_indent(desc)
             out += ['']
@@ -341,7 +346,8 @@ class NumpyDocString(object):
         return out
 
     def _str_see_also(self, func_role):
-        if not self['See Also']: return []
+        if not self['See Also']:
+            return []
         out = []
         out += self._str_header("See Also")
         last_had_desc = True
@@ -368,7 +374,7 @@ class NumpyDocString(object):
     def _str_index(self):
         idx = self['index']
         out = []
-        out += ['.. index:: %s' % idx.get('default','')]
+        out += ['.. index:: %s' % idx.get('default', '')]
         for section, references in idx.iteritems():
             if section == 'default':
                 continue
@@ -380,41 +386,43 @@ class NumpyDocString(object):
         out += self._str_signature()
         out += self._str_summary()
         out += self._str_extended_summary()
-        for param_list in ('Parameters','Returns','Raises'):
+        for param_list in ('Parameters', 'Returns', 'Raises'):
             out += self._str_param_list(param_list)
         out += self._str_section('Warnings')
         out += self._str_see_also(func_role)
-        for s in ('Notes','References','Examples'):
+        for s in ('Notes', 'References', 'Examples'):
             out += self._str_section(s)
         out += self._str_index()
         return '\n'.join(out)
 
 
-def indent(str,indent=4):
-    indent_str = ' '*indent
+def indent(str, indent=4):
+    indent_str = ' ' * indent
     if str is None:
         return indent_str
     lines = str.split('\n')
     return '\n'.join(indent_str + l for l in lines)
 
+
 def dedent_lines(lines):
     """Deindent a list of lines maximally"""
     return textwrap.dedent("\n".join(lines)).split("\n")
 
+
 def header(text, style='-'):
-    return text + '\n' + style*len(text) + '\n'
+    return text + '\n' + style * len(text) + '\n'
 
 
 class FunctionDoc(NumpyDocString):
     def __init__(self, func, role='func'):
         self._f = func
-        self._role = role # e.g. "func" or "meth"
+        self._role = role  # e.g. "func" or "meth"
         try:
-            NumpyDocString.__init__(self,inspect.getdoc(func) or '')
+            NumpyDocString.__init__(self, inspect.getdoc(func) or '')
         except ValueError, e:
-            print '*'*78
+            print '*' * 78
             print "ERROR: '%s' while parsing `%s`" % (e, self._f)
-            print '*'*78
+            print '*' * 78
             #print "Docstring follows:"
             #print doclines
             #print '='*78
@@ -425,7 +433,7 @@ class FunctionDoc(NumpyDocString):
                 # try to read signature
                 argspec = inspect.getargspec(func)
                 argspec = inspect.formatargspec(*argspec)
-                argspec = argspec.replace('*','\*')
+                argspec = argspec.replace('*', '\*')
                 signature = '%s%s' % (func_name, argspec)
             except TypeError, e:
                 signature = '%s()' % func_name
@@ -451,7 +459,7 @@ class FunctionDoc(NumpyDocString):
         if self._role:
             if not roles.has_key(self._role):
                 print "Warning: invalid role %s" % self._role
-            out += '.. %s:: %s\n    \n\n' % (roles.get(self._role,''),
+            out += '.. %s:: %s\n    \n\n' % (roles.get(self._role, ''),
                                              func_name)
 
         out += super(FunctionDoc, self).__str__(func_role=self._role)
@@ -459,7 +467,7 @@ class FunctionDoc(NumpyDocString):
 
 
 class ClassDoc(NumpyDocString):
-    def __init__(self,cls,modulename='',func_doc=FunctionDoc):
+    def __init__(self, cls, modulename='', func_doc=FunctionDoc):
         if not inspect.isclass(cls):
             raise ValueError("Initialise using a class. Got %r" % cls)
         self._cls = cls
@@ -474,7 +482,7 @@ class ClassDoc(NumpyDocString):
 
     @property
     def methods(self):
-        return [name for name,func in inspect.getmembers(self._cls)
+        return [name for name, func in inspect.getmembers(self._cls)
                 if not name.startswith('_') and callable(func)]
 
     def __str__(self):
@@ -488,5 +496,3 @@ class ClassDoc(NumpyDocString):
         #    out += '.. index::\n   single: %s; %s\n\n' % (self._name, m)
 
         return out
-
-
diff --git a/doc/sphinxext/numpy_ext_old/docscrape_sphinx.py b/doc/sphinxext/numpy_ext_old/docscrape_sphinx.py
index d431ecd3f900f53fff222070a120898e27a74aae..3e1d666e06607585ca8ee7c3dbab309ce859e5a2 100644
--- a/doc/sphinxext/numpy_ext_old/docscrape_sphinx.py
+++ b/doc/sphinxext/numpy_ext_old/docscrape_sphinx.py
@@ -1,5 +1,12 @@
-import re, inspect, textwrap, pydoc
-from docscrape import NumpyDocString, FunctionDoc, ClassDoc
+import re
+import inspect
+import textwrap
+import pydoc
+
+from docscrape import NumpyDocString
+from docscrape FunctionDoc
+from docscrape ClassDoc
+
 
 class SphinxDocString(NumpyDocString):
     # string conversion routines
@@ -12,7 +19,7 @@ class SphinxDocString(NumpyDocString):
     def _str_indent(self, doc, indent=4):
         out = []
         for line in doc:
-            out += [' '*indent + line]
+            out += [' ' * indent + line]
         return out
 
     def _str_signature(self):
@@ -33,11 +40,11 @@ class SphinxDocString(NumpyDocString):
         if self[name]:
             out += self._str_field_list(name)
             out += ['']
-            for param,param_type,desc in self[name]:
+            for param, param_type, desc in self[name]:
                 out += self._str_indent(['**%s** : %s' % (param.strip(),
                                                           param_type)])
                 out += ['']
-                out += self._str_indent(desc,8)
+                out += self._str_indent(desc, 8)
                 out += ['']
         return out
 
@@ -72,7 +79,7 @@ class SphinxDocString(NumpyDocString):
         if len(idx) == 0:
             return out
 
-        out += ['.. index:: %s' % idx.get('default','')]
+        out += ['.. index:: %s' % idx.get('default', '')]
         for section, references in idx.iteritems():
             if section == 'default':
                 continue
@@ -99,22 +106,25 @@ class SphinxDocString(NumpyDocString):
         out += self._str_summary()
         out += self._str_extended_summary()
         for param_list in ('Parameters', 'Attributes', 'Methods',
-                           'Returns','Raises'):
+                           'Returns', 'Raises'):
             out += self._str_param_list(param_list)
         out += self._str_warnings()
         out += self._str_see_also(func_role)
         out += self._str_section('Notes')
         out += self._str_references()
         out += self._str_section('Examples')
-        out = self._str_indent(out,indent)
+        out = self._str_indent(out, indent)
         return '\n'.join(out)
 
+
 class SphinxFunctionDoc(SphinxDocString, FunctionDoc):
     pass
 
+
 class SphinxClassDoc(SphinxDocString, ClassDoc):
     pass
 
+
 def get_doc_object(obj, what=None):
     if what is None:
         if inspect.isclass(obj):
diff --git a/doc/sphinxext/numpy_ext_old/numpydoc.py b/doc/sphinxext/numpy_ext_old/numpydoc.py
index 5e979ea9c837edb8ab6ce4380fabb91a1ce71c41..6e69d4601f9a3755e37142f3995a91c35472c02e 100644
--- a/doc/sphinxext/numpy_ext_old/numpydoc.py
+++ b/doc/sphinxext/numpy_ext_old/numpydoc.py
@@ -16,16 +16,21 @@ It will:
 
 """
 
-import os, re, pydoc
-from docscrape_sphinx import get_doc_object, SphinxDocString
+import os
+import re
+import pydoc
 import inspect
 
+from docscrape_sphinx import get_doc_object
+from docscrape_sphinx import SphinxDocString
+
+
 def mangle_docstrings(app, what, name, obj, options, lines,
                       reference_offset=[0]):
     if what == 'module':
         # Strip top title
         title_re = re.compile(r'^\s*[#*=]{4,}\n[a-z0-9 -]+\n[#*=]{4,}\s*',
-                              re.I|re.S)
+                              re.I | re.S)
         lines[:] = title_re.sub('', "\n".join(lines)).split("\n")
     else:
         doc = get_doc_object(obj, what)
@@ -60,26 +65,31 @@ def mangle_docstrings(app, what, name, obj, options, lines,
 
     reference_offset[0] += len(references)
 
+
 def mangle_signature(app, what, name, obj, options, sig, retann):
     # Do not try to inspect classes that don't define `__init__`
     if (inspect.isclass(obj) and
         'initializes x; see ' in pydoc.getdoc(obj.__init__)):
         return '', ''
 
-    if not (callable(obj) or hasattr(obj, '__argspec_is_invalid_')): return
-    if not hasattr(obj, '__doc__'): return
+    if not (callable(obj) or hasattr(obj, '__argspec_is_invalid_')):
+        return
+    if not hasattr(obj, '__doc__'):
+        return
 
     doc = SphinxDocString(pydoc.getdoc(obj))
     if doc['Signature']:
         sig = re.sub("^[^(]*", "", doc['Signature'])
         return sig, ''
 
+
 def initialize(app):
     try:
         app.connect('autodoc-process-signature', mangle_signature)
     except:
         monkeypatch_sphinx_ext_autodoc()
 
+
 def setup(app, get_doc_object_=get_doc_object):
     global get_doc_object
     get_doc_object = get_doc_object_
@@ -92,6 +102,7 @@ def setup(app, get_doc_object_=get_doc_object):
 # Monkeypatch sphinx.ext.autodoc to accept argspecless autodocs (Sphinx < 0.5)
 #------------------------------------------------------------------------------
 
+
 def monkeypatch_sphinx_ext_autodoc():
     global _original_format_signature
     import sphinx.ext.autodoc
@@ -103,6 +114,7 @@ def monkeypatch_sphinx_ext_autodoc():
     _original_format_signature = sphinx.ext.autodoc.format_signature
     sphinx.ext.autodoc.format_signature = our_format_signature
 
+
 def our_format_signature(what, obj):
     r = mangle_signature(None, what, None, obj, None, None, None)
     if r is not None: