Skip to content

Commit ae46bd0

Browse files
committed
2to3: Use absolute imports.
The new import `absolute_import` is added the `from __future__ import` statement and The 2to3 `import` fixer is run to make the imports compatible. There are several things that need to be dealt with to make this work. 1) Files meant to be run as scripts run in a different environment than files imported as part of a package, and so changes to those files need to be skipped. The affected script files are: * all setup.py files * numpy/core/code_generators/generate_umath.py * numpy/core/code_generators/generate_numpy_api.py * numpy/core/code_generators/generate_ufunc_api.py 2) Some imported modules are not available as they are created during the build process and consequently 2to3 is unable to handle them correctly. Files that import those modules need a bit of extra work. The affected files are: * core/__init__.py, * core/numeric.py, * core/_internal.py, * core/arrayprint.py, * core/fromnumeric.py, * numpy/__init__.py, * lib/npyio.py, * lib/function_base.py, * fft/fftpack.py, * random/__init__.py Closes #3172
1 parent d00e78a commit ae46bd0

File tree

10 files changed

+10
-10
lines changed

10 files changed

+10
-10
lines changed

numpydoc/comment_eater.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from __future__ import division
1+
from __future__ import division, absolute_import
22

33
import sys
44
if sys.version_info[0] >= 3:

numpydoc/compiler_unparse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
fixme: We may want to move to using _ast trees because the compiler for
1111
them is about 6 times faster than compiler.compile.
1212
"""
13-
from __future__ import division
13+
from __future__ import division, absolute_import
1414

1515
import sys
1616
from compiler.ast import Const, Name, Tuple, Div, Mul, Sub, Add

numpydoc/docscrape.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Extract reference documentation from the NumPy source tree.
22
33
"""
4-
from __future__ import division
4+
from __future__ import division, absolute_import
55

66
import sys
77
import inspect

numpydoc/docscrape_sphinx.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from __future__ import division
1+
from __future__ import division, absolute_import
22

33
import re, inspect, textwrap, pydoc
44
import sphinx

numpydoc/linkcode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
:license: BSD, see LICENSE for details.
1010
1111
"""
12-
from __future__ import division
12+
from __future__ import division, absolute_import
1313

1414
import warnings
1515
import collections

numpydoc/numpydoc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
.. [1] https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt
1616
1717
"""
18-
from __future__ import division
18+
from __future__ import division, absolute_import
1919

2020
import sphinx
2121
import collections

numpydoc/phantom_import.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
.. [1] http://code.google.com/p/pydocweb
1515
1616
"""
17-
from __future__ import division
17+
from __future__ import division, absolute_import
1818

1919
import imp, sys, compiler, types, os, inspect, re
2020

numpydoc/plot_directive.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
to make them appear side-by-side, or in floats.
7575
7676
"""
77-
from __future__ import division
77+
from __future__ import division, absolute_import
7878

7979
import sys, os, glob, shutil, imp, warnings, re, textwrap, traceback
8080
import sphinx

numpydoc/tests/test_docscrape.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- encoding:utf-8 -*-
2-
from __future__ import division
2+
from __future__ import division, absolute_import
33

44
import sys, textwrap
55

numpydoc/traitsdoc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
.. [2] http://code.enthought.com/projects/traits/
1414
1515
"""
16-
from __future__ import division
16+
from __future__ import division, absolute_import
1717

1818
import inspect
1919
import os

0 commit comments

Comments
 (0)