Skip to content

Commit

Permalink
2to3: Put `from __future__ import division in every python file.
Browse files Browse the repository at this point in the history
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
charris committed Mar 1, 2013
1 parent 3c13c0a commit 6aa264c
Show file tree
Hide file tree
Showing 395 changed files with 975 additions and 237 deletions.
2 changes: 2 additions & 0 deletions doc/cdoc/numpyfilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
Also, add Doxygen /** and /**< syntax automatically where appropriate.
"""
from __future__ import division

import sys
import re
import os
Expand Down
2 changes: 2 additions & 0 deletions doc/cython/run_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python
from __future__ import division

from numpyx import test
test()
2 changes: 2 additions & 0 deletions doc/cython/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions doc/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
Expand Down
2 changes: 2 additions & 0 deletions doc/newdtype_example/example.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import division

import floatint.floatint as ff
import numpy as np

Expand Down
3 changes: 3 additions & 0 deletions doc/newdtype_example/floatint/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from __future__ import division


1 change: 1 addition & 0 deletions doc/newdtype_example/setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import division

from numpy.distutils.core import setup

Expand Down
2 changes: 2 additions & 0 deletions doc/numpybook/comparison/ctypes/filter.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import division

__all__ = ['filter2d']

import numpy as N
Expand Down
2 changes: 2 additions & 0 deletions doc/numpybook/comparison/ctypes/interface.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import division

__all__ = ['add', 'filter2d']

import numpy as N
Expand Down
1 change: 1 addition & 0 deletions doc/numpybook/comparison/pyrex/setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
from __future__ import division

from distutils.core import setup
from distutils.extension import Extension
Expand Down
1 change: 1 addition & 0 deletions doc/numpybook/comparison/timing.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import division

import timeit

Expand Down
2 changes: 2 additions & 0 deletions doc/numpybook/comparison/weave/filter.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import division

from scipy import weave, zeros_like

def filter(a):
Expand Down
2 changes: 2 additions & 0 deletions doc/numpybook/comparison/weave/inline.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import division

from scipy import weave
from numpy import rand, zeros_like

Expand Down
31 changes: 17 additions & 14 deletions doc/numpybook/runcode.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions doc/postprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
MODE is either 'html' or 'tex'.
"""
from __future__ import division

import re, optparse

def main():
Expand Down
2 changes: 2 additions & 0 deletions doc/pyrex/run_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python
from __future__ import division

from numpyx import test
test()
2 changes: 2 additions & 0 deletions doc/pyrex/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import division

import sys, os, re

Expand Down
2 changes: 2 additions & 0 deletions doc/sphinxext/numpydoc/comment_eater.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import division

import sys
if sys.version_info[0] >= 3:
from io import StringIO
Expand Down
1 change: 1 addition & 0 deletions doc/sphinxext/numpydoc/compiler_unparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions doc/sphinxext/numpydoc/docscrape.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Extract reference documentation from the NumPy source tree.
"""
from __future__ import division

import sys
import inspect
Expand Down
2 changes: 2 additions & 0 deletions doc/sphinxext/numpydoc/docscrape_sphinx.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import division

import re, inspect, textwrap, pydoc
import sphinx
import collections
Expand Down
2 changes: 2 additions & 0 deletions doc/sphinxext/numpydoc/linkcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions doc/sphinxext/numpydoc/numpydoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions doc/sphinxext/numpydoc/phantom_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 2 additions & 1 deletion doc/sphinxext/numpydoc/plot_directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions doc/sphinxext/numpydoc/tests/test_docscrape.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- encoding:utf-8 -*-
from __future__ import division

import sys, textwrap

Expand Down
1 change: 1 addition & 0 deletions doc/sphinxext/numpydoc/traitsdoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
.. [2] http://code.enthought.com/projects/traits/
"""
from __future__ import division

import inspect
import os
Expand Down
2 changes: 2 additions & 0 deletions doc/sphinxext/setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import division

import setuptools
from distutils.core import setup

Expand Down
1 change: 1 addition & 0 deletions doc/summarize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions doc/swig/test/setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#! /usr/bin/env python
from __future__ import division

# System imports
from distutils.core import *
Expand Down
1 change: 1 addition & 0 deletions doc/swig/test/testArray.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#! /usr/bin/env python
from __future__ import division

# System imports
from distutils.util import get_platform
Expand Down
1 change: 1 addition & 0 deletions doc/swig/test/testFarray.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#! /usr/bin/env python
from __future__ import division

# System imports
from distutils.util import get_platform
Expand Down
1 change: 1 addition & 0 deletions doc/swig/test/testFortran.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#! /usr/bin/env python
from __future__ import division

# System imports
from distutils.util import get_platform
Expand Down
1 change: 1 addition & 0 deletions doc/swig/test/testMatrix.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#! /usr/bin/env python
from __future__ import division

# System imports
from distutils.util import get_platform
Expand Down
1 change: 1 addition & 0 deletions doc/swig/test/testTensor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#! /usr/bin/env python
from __future__ import division

# System imports
from distutils.util import get_platform
Expand Down
1 change: 1 addition & 0 deletions doc/swig/test/testVector.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#! /usr/bin/env python
from __future__ import division

# System imports
from distutils.util import get_platform
Expand Down
1 change: 1 addition & 0 deletions numpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions numpy/_import_tools.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import division

import os
import sys

Expand Down
16 changes: 10 additions & 6 deletions numpy/add_newdocs.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
1 change: 1 addition & 0 deletions numpy/build_utils/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from __future__ import division
2 changes: 2 additions & 0 deletions numpy/build_utils/common.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import division

import sys
import copy
import binascii
Expand Down
2 changes: 2 additions & 0 deletions numpy/build_utils/waf.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import division

import os
import re

Expand Down
2 changes: 2 additions & 0 deletions numpy/compat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions numpy/compat/_inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions numpy/compat/py3k.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Python 3 compatibility tools.
"""
from __future__ import division

__all__ = ['bytes', 'asbytes', 'isfileobj', 'getexception', 'strchar',
'unicode', 'asunicode', 'asbytes_nested', 'asunicode_nested',
Expand Down
2 changes: 2 additions & 0 deletions numpy/compat/setup.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions numpy/core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import division

from info import __doc__
from numpy.version import version as __version__
Expand Down
9 changes: 7 additions & 2 deletions numpy/core/_internal.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Loading

0 comments on commit 6aa264c

Please sign in to comment.