diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2013-06-09 21:44:06 -0600 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2013-06-10 16:30:10 -0600 |
commit | a9a470c841eeb5f0fb2c2ae9639f6c2833f03d00 (patch) | |
tree | 096b749d7857c78677e6222eb8fadad5b7cfccd7 /numpy | |
parent | 75cdf3d82e96e4fb605f3b0ea85961bbc24e70d8 (diff) | |
download | numpy-a9a470c841eeb5f0fb2c2ae9639f6c2833f03d00.tar.gz |
DEP: Deprecate the oldnumeric and numarray modules.
The numarray and oldnumeric modules are deprecated. This is a bit tricky
as raising a DeprecationWarning on import causes an error when tests are
run. To deal with that, a ModuleDeprecationWarning class is added to
numpy and NoseTester is modified to ignore that warning during testing.
Closes #2905
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/__init__.py | 15 | ||||
-rw-r--r-- | numpy/numarray/__init__.py | 6 | ||||
-rw-r--r-- | numpy/oldnumeric/__init__.py | 6 | ||||
-rw-r--r-- | numpy/testing/nosetester.py | 2 | ||||
-rw-r--r-- | numpy/testing/utils.py | 2 |
5 files changed, 30 insertions, 1 deletions
diff --git a/numpy/__init__.py b/numpy/__init__.py index bbbecd6f6..b4be4d707 100644 --- a/numpy/__init__.py +++ b/numpy/__init__.py @@ -108,6 +108,19 @@ from __future__ import division, absolute_import, print_function import sys + +class ModuleDeprecationWarning(DeprecationWarning): + """Module deprecation warning. + + The nose tester turns ordinary Deprecation warnings into test failures. + That makes it hard to deprecate whole modules, because they get + imported by default. So this is a special Deprecation warning that the + nose tester will let pass without making tests fail. + + """ + pass + + # We first need to detect if we're being called as part of the numpy setup # procedure itself in a reliable manner. try: @@ -138,7 +151,7 @@ else: return loader(*packages, **options) from . import add_newdocs - __all__ = ['add_newdocs'] + __all__ = ['add_newdocs', 'ModuleDeprecationWarning'] pkgload.__doc__ = PackageLoader.__call__.__doc__ diff --git a/numpy/numarray/__init__.py b/numpy/numarray/__init__.py index 706ec1c33..468324ced 100644 --- a/numpy/numarray/__init__.py +++ b/numpy/numarray/__init__.py @@ -1,5 +1,8 @@ from __future__ import division, absolute_import, print_function +import warnings +from numpy import ModuleDeprecationWarning + from .util import * from .numerictypes import * from .functions import * @@ -14,6 +17,9 @@ from . import ufuncs from . import compat from . import session +_msg = "The numarray module will be dropped in Numpy 1.9" +warnings.warn(_msg, ModuleDeprecationWarning) + __all__ = ['session', 'numerictypes'] __all__ += util.__all__ __all__ += numerictypes.__all__ diff --git a/numpy/oldnumeric/__init__.py b/numpy/oldnumeric/__init__.py index cf34b8300..86cdf55f7 100644 --- a/numpy/oldnumeric/__init__.py +++ b/numpy/oldnumeric/__init__.py @@ -3,8 +3,14 @@ """ from __future__ import division, absolute_import, print_function +import warnings + from numpy import * +_msg = "The oldnumeric module will be dropped in Numpy 1.9" +warnings.warn(_msg, ModuleDeprecationWarning) + + def _move_axis_to_0(a, axis): if axis == 0: return a diff --git a/numpy/testing/nosetester.py b/numpy/testing/nosetester.py index e3f96b9a9..f1ebd2265 100644 --- a/numpy/testing/nosetester.py +++ b/numpy/testing/nosetester.py @@ -11,6 +11,7 @@ import sys import warnings import numpy.testing.utils from numpy.compat import basestring +from numpy import ModuleDeprecationWarning def get_package_name(filepath): """ @@ -378,6 +379,7 @@ class NoseTester(object): warnings.filterwarnings('ignore', message='Not importing directory') warnings.filterwarnings("ignore", message="numpy.dtype size changed") warnings.filterwarnings("ignore", message="numpy.ufunc size changed") + warnings.filterwarnings("ignore", category=ModuleDeprecationWarning) try: from .noseclasses import NumpyTestProgram diff --git a/numpy/testing/utils.py b/numpy/testing/utils.py index 2d8d57c5f..f58997d58 100644 --- a/numpy/testing/utils.py +++ b/numpy/testing/utils.py @@ -26,8 +26,10 @@ __all__ = ['assert_equal', 'assert_almost_equal','assert_approx_equal', 'assert_array_max_ulp', 'assert_warns', 'assert_no_warnings', 'assert_allclose'] + verbose = 0 + def assert_(val, msg='') : """ Assert that works in release mode. |