Permalink
Browse files

2to3: Put `from __future__ import division in every python file.

This should be harmless, as we already are division clean. However,
placement of this import takes some care. In the future a script
can be used to append new features without worry, at least until
such time as it exceeds a single line. Having that ability will
make it easier to deal with absolute imports and printing updates.
  • Loading branch information...
1 parent 3c13c0a commit 6aa264c4bad9c89ccdd9ecd5a1cb5ef10643ec51 @charris charris committed Feb 27, 2013
Showing 395 changed files with 975 additions and 237 deletions.
@@ -6,6 +6,8 @@
Also, add Doxygen /** and /**< syntax automatically where appropriate.
"""
+from __future__ import division
+
import sys
import re
import os
@@ -1,3 +1,5 @@
#!/usr/bin/env python
+from __future__ import division
+
from numpyx import test
test()
View
@@ -3,7 +3,9 @@
Note: Cython is the successor project to Pyrex. For more information, see
http://cython.org.
+
"""
+from __future__ import division
from distutils.core import setup
from distutils.extension import Extension
View
@@ -8,6 +8,8 @@
a line by itself, preferably preceeded by a blank line.
"""
+from __future__ import division
+
import os # standard library imports first
# Do NOT import using *, e.g. from numpy import *
@@ -1,3 +1,5 @@
+from __future__ import division
+
import floatint.floatint as ff
import numpy as np
@@ -0,0 +1,3 @@
+from __future__ import division
+
+
@@ -1,3 +1,4 @@
+from __future__ import division
from numpy.distutils.core import setup
@@ -1,3 +1,5 @@
+from __future__ import division
+
__all__ = ['filter2d']
import numpy as N
@@ -1,3 +1,5 @@
+from __future__ import division
+
__all__ = ['add', 'filter2d']
import numpy as N
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from __future__ import division
from distutils.core import setup
from distutils.extension import Extension
@@ -1,3 +1,4 @@
+from __future__ import division
import timeit
@@ -1,3 +1,5 @@
+from __future__ import division
+
from scipy import weave, zeros_like
def filter(a):
@@ -1,3 +1,5 @@
+from __future__ import division
+
from scipy import weave
from numpy import rand, zeros_like
@@ -1,17 +1,20 @@
-# This script takes a lyx file and runs the python code in it.
-# Then rewrites the lyx file again.
-#
-# Each section of code portion is assumed to be in the same namespace
-# where a from numpy import * has been applied
-#
-# If a PYNEW inside a Note is encountered, the name space is restarted
-#
-# The output (if any) is replaced in the file
-# by the output produced during the code run.
-#
-# Options:
-# -n name of code section (default MyCode)
-#
+"""
+This script takes a lyx file and runs the python code in it.
+ Then rewrites the lyx file again.
+
+Each section of code portion is assumed to be in the same namespace
+where a from numpy import * has been applied
+
+ If a PYNEW inside a Note is encountered, the name space is restarted
+
+The output (if any) is replaced in the file
+ by the output produced during the code run.
+
+Options:
+ -n name of code section (default MyCode)
+
+"""
+from __future__ import division
import sys
import optparse
View
@@ -6,6 +6,8 @@
MODE is either 'html' or 'tex'.
"""
+from __future__ import division
+
import re, optparse
def main():
@@ -1,3 +1,5 @@
#!/usr/bin/env python
+from __future__ import division
+
from numpyx import test
test()
View
@@ -10,7 +10,9 @@
For more details, see:
http://www.scipy.org/Cookbook/Pyrex_and_NumPy
http://www.scipy.org/Cookbook/ArrayStruct_and_Pyrex
+
"""
+from __future__ import division
from distutils.core import setup
from distutils.extension import Extension
View
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
+from __future__ import division
import sys, os, re
@@ -1,3 +1,5 @@
+from __future__ import division
+
import sys
if sys.version_info[0] >= 3:
from io import StringIO
@@ -10,6 +10,7 @@
fixme: We may want to move to using _ast trees because the compiler for
them is about 6 times faster than compiler.compile.
"""
+from __future__ import division
import sys
from compiler.ast import Const, Name, Tuple, Div, Mul, Sub, Add
@@ -1,6 +1,7 @@
"""Extract reference documentation from the NumPy source tree.
"""
+from __future__ import division
import sys
import inspect
@@ -1,3 +1,5 @@
+from __future__ import division
+
import re, inspect, textwrap, pydoc
import sphinx
import collections
@@ -7,7 +7,9 @@
:copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
+
"""
+from __future__ import division
import warnings
import collections
@@ -15,6 +15,7 @@
.. [1] https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt
"""
+from __future__ import division
import sphinx
import collections
@@ -14,6 +14,8 @@
.. [1] http://code.google.com/p/pydocweb
"""
+from __future__ import division
+
import imp, sys, compiler, types, os, inspect, re
def setup(app):
@@ -74,6 +74,7 @@
to make them appear side-by-side, or in floats.
"""
+from __future__ import division
import sys, os, glob, shutil, imp, warnings, re, textwrap, traceback
import sphinx
@@ -99,7 +100,7 @@ def setup(app):
setup.app = app
setup.config = app.config
setup.confdir = app.confdir
-
+
app.add_config_value('plot_pre_code', '', True)
app.add_config_value('plot_include_source', False, True)
app.add_config_value('plot_formats', ['png', 'hires.png', 'pdf'], True)
@@ -1,4 +1,5 @@
# -*- encoding:utf-8 -*-
+from __future__ import division
import sys, textwrap
@@ -13,6 +13,7 @@
.. [2] http://code.enthought.com/projects/traits/
"""
+from __future__ import division
import inspect
import os
@@ -1,3 +1,5 @@
+from __future__ import division
+
import setuptools
from distutils.core import setup
View
@@ -5,6 +5,7 @@
Show a summary about which Numpy functions are documented and which are not.
"""
+from __future__ import division
import os, glob, re, sys, inspect, optparse
import collections
@@ -1,4 +1,5 @@
#! /usr/bin/env python
+from __future__ import division
# System imports
from distutils.core import *
@@ -1,4 +1,5 @@
#! /usr/bin/env python
+from __future__ import division
# System imports
from distutils.util import get_platform
@@ -1,4 +1,5 @@
#! /usr/bin/env python
+from __future__ import division
# System imports
from distutils.util import get_platform
@@ -1,4 +1,5 @@
#! /usr/bin/env python
+from __future__ import division
# System imports
from distutils.util import get_platform
@@ -1,4 +1,5 @@
#! /usr/bin/env python
+from __future__ import division
# System imports
from distutils.util import get_platform
@@ -1,4 +1,5 @@
#! /usr/bin/env python
+from __future__ import division
# System imports
from distutils.util import get_platform
@@ -1,4 +1,5 @@
#! /usr/bin/env python
+from __future__ import division
# System imports
from distutils.util import get_platform
View
@@ -104,6 +104,7 @@
Exceptions to this rule are documented.
"""
+from __future__ import division
# We first need to detect if we're being called as part of the numpy setup
# procedure itself in a reliable manner.
@@ -1,3 +1,5 @@
+from __future__ import division
+
import os
import sys
View
@@ -1,10 +1,14 @@
-# This is only meant to add docs to objects defined in C-extension modules.
-# The purpose is to allow easier editing of the docstrings without
-# requiring a re-compile.
+"""
+This is only meant to add docs to objects defined in C-extension modules.
+The purpose is to allow easier editing of the docstrings without
+requiring a re-compile.
-# NOTE: Many of the methods of ndarray have corresponding functions.
-# If you update these docstrings, please keep also the ones in
-# core/fromnumeric.py, core/defmatrix.py up-to-date.
+NOTE: Many of the methods of ndarray have corresponding functions.
+ If you update these docstrings, please keep also the ones in
+ core/fromnumeric.py, core/defmatrix.py up-to-date.
+
+"""
+from __future__ import division
from numpy.lib import add_newdoc
@@ -0,0 +1 @@
+from __future__ import division
@@ -1,3 +1,5 @@
+from __future__ import division
+
import sys
import copy
import binascii
@@ -1,3 +1,5 @@
+from __future__ import division
+
import os
import re
@@ -8,6 +8,8 @@
* we may only need a small subset of the copied library/module
"""
+from __future__ import division
+
import _inspect
import py3k
from _inspect import getargspec, formatargspec
@@ -3,7 +3,9 @@
We use this instead of upstream because upstream inspect is slow to import, and
significanly contributes to numpy import times. Importing this copy has almost
no overhead.
+
"""
+from __future__ import division
import types
@@ -2,6 +2,7 @@
Python 3 compatibility tools.
"""
+from __future__ import division
__all__ = ['bytes', 'asbytes', 'isfileobj', 'getexception', 'strchar',
'unicode', 'asunicode', 'asbytes_nested', 'asunicode_nested',
@@ -1,4 +1,6 @@
#!/usr/bin/env python
+from __future__ import division
+
def configuration(parent_package='',top_path=None):
from numpy.distutils.misc_util import Configuration
@@ -1,3 +1,4 @@
+from __future__ import division
from info import __doc__
from numpy.version import version as __version__
@@ -1,5 +1,10 @@
-#A place for code to be called from C-code
-# that implements more complicated stuff.
+"""
+A place for code to be called from core C-code.
+
+Some things are more easily handled Python.
+
+"""
+from __future__ import division
import re
import sys
Oops, something went wrong.

0 comments on commit 6aa264c

Please sign in to comment.