diff options
author | Ralf Gommers <ralf.gommers@googlemail.com> | 2013-08-10 10:42:59 +0200 |
---|---|---|
committer | Ralf Gommers <ralf.gommers@googlemail.com> | 2013-08-10 10:50:36 +0200 |
commit | d6e8c91cc8d4cf173f7378eba69bcf1e933dd879 (patch) | |
tree | c07011b060d5c8639f2aa24b3f664134e4065451 /numpy/testing | |
parent | 928289bf37081f4deb6755e226600998ccc23610 (diff) | |
download | numpy-d6e8c91cc8d4cf173f7378eba69bcf1e933dd879.tar.gz |
MAINT: remove unused and broken parts of numpy.testing
Deprecate np.testing.importall - it's pointless and partially broken.
Diffstat (limited to 'numpy/testing')
-rw-r--r-- | numpy/testing/__init__.py | 2 | ||||
-rw-r--r-- | numpy/testing/decorators.py | 2 | ||||
-rw-r--r-- | numpy/testing/nosetester.py | 3 | ||||
-rw-r--r-- | numpy/testing/nulltester.py | 17 | ||||
-rw-r--r-- | numpy/testing/numpytest.py | 30 | ||||
-rw-r--r-- | numpy/testing/utils.py | 14 |
6 files changed, 21 insertions, 47 deletions
diff --git a/numpy/testing/__init__.py b/numpy/testing/__init__.py index 4265eddcf..aad448c96 100644 --- a/numpy/testing/__init__.py +++ b/numpy/testing/__init__.py @@ -11,7 +11,7 @@ from unittest import TestCase from . import decorators as dec from .utils import * -from .numpytest import * +from .numpytest import importall # remove for numpy 1.9.0 from .nosetester import NoseTester as Tester from .nosetester import run_module_suite test = Tester().test diff --git a/numpy/testing/decorators.py b/numpy/testing/decorators.py index 8d1fb04bb..91659bb8d 100644 --- a/numpy/testing/decorators.py +++ b/numpy/testing/decorators.py @@ -15,10 +15,10 @@ function name, setup and teardown functions and so on - see """ from __future__ import division, absolute_import, print_function -import sys import warnings import collections + def slow(t): """ Label a test as 'slow'. diff --git a/numpy/testing/nosetester.py b/numpy/testing/nosetester.py index f11f04b20..212afe79b 100644 --- a/numpy/testing/nosetester.py +++ b/numpy/testing/nosetester.py @@ -9,10 +9,10 @@ from __future__ import division, absolute_import, print_function import os import sys import warnings -import numpy.testing.utils from numpy.compat import basestring from numpy import ModuleDeprecationWarning + def get_package_name(filepath): """ Given a path where a package is installed, determine its name. @@ -60,7 +60,6 @@ def import_nose(): minimum_nose_version = (0,10,0) try: import nose - from nose.tools import raises except ImportError: fine_nose = False else: diff --git a/numpy/testing/nulltester.py b/numpy/testing/nulltester.py deleted file mode 100644 index d94d8ed50..000000000 --- a/numpy/testing/nulltester.py +++ /dev/null @@ -1,17 +0,0 @@ -""" Null tester to signal nose tests disabled - -Merely returns error reporting lack of nose package or version number -below requirements. - -See pkgtester, nosetester modules - -""" -from __future__ import division, absolute_import, print_function - - -class NullTester(object): - def test(self, labels=None, *args, **kwargs): - raise ImportError( - 'Need nose >=0.10 for tests - see %s' % - 'http://somethingaboutorange.com/mrl/projects/nose') - bench = test diff --git a/numpy/testing/numpytest.py b/numpy/testing/numpytest.py index 4fa9364b1..2120975df 100644 --- a/numpy/testing/numpytest.py +++ b/numpy/testing/numpytest.py @@ -1,36 +1,20 @@ from __future__ import division, absolute_import, print_function import os -import sys -import traceback +import warnings -__all__ = ['IgnoreException', 'importall',] +__all__ = ['importall'] -DEBUG=0 -get_frame = sys._getframe - -class IgnoreException(Exception): - "Ignoring this exception due to disabled feature" - - -def output_exception(printstream = sys.stdout): - try: - type, value, tb = sys.exc_info() - info = traceback.extract_tb(tb) - #this is more verbose - #traceback.print_exc() - filename, lineno, function, text = info[-1] # last line only - msg = "%s:%d: %s: %s (in %s)\n" % ( - filename, lineno, type.__name__, str(value), function) - printstream.write(msg) - finally: - type = value = tb = None # clean up - return def importall(package): """ + `importall` is DEPRECATED and will be removed in numpy 1.9.0 + Try recursively to import all subpackages under package. """ + warnings.warn("`importall is deprecated, and will be remobed in numpy 1.9.0", + DeprecationWarning) + if isinstance(package,str): package = __import__(package) diff --git a/numpy/testing/utils.py b/numpy/testing/utils.py index bc0c59502..235b9e0ba 100644 --- a/numpy/testing/utils.py +++ b/numpy/testing/utils.py @@ -24,7 +24,7 @@ __all__ = ['assert_equal', 'assert_almost_equal','assert_approx_equal', 'raises', 'rand', 'rundocs', 'runstring', 'verbose', 'measure', 'assert_', 'assert_array_almost_equal_nulp', 'assert_array_max_ulp', 'assert_warns', 'assert_no_warnings', - 'assert_allclose'] + 'assert_allclose', 'IgnoreException'] verbose = 0 @@ -915,7 +915,9 @@ def assert_string_equal(actual, desired): raise AssertionError(repr(type(actual))) if not isinstance(desired, str): raise AssertionError(repr(type(desired))) - if re.match(r'\A'+desired+r'\Z', actual, re.M): return + if re.match(r'\A'+desired+r'\Z', actual, re.M): + return + diff = list(difflib.Differ().compare(actual.splitlines(1), desired.splitlines(1))) diff_list = [] while diff: @@ -1172,6 +1174,7 @@ def assert_allclose(actual, desired, rtol=1e-7, atol=0, import numpy as np def compare(x, y): return np.allclose(x, y, rtol=rtol, atol=atol) + actual, desired = np.asanyarray(actual), np.asanyarray(desired) header = 'Not equal to tolerance rtol=%g, atol=%g' % (rtol, atol) assert_array_compare(compare, actual, desired, err_msg=str(err_msg), @@ -1494,7 +1497,7 @@ def assert_no_warnings(func, *args, **kw): Arguments passed to `func`. \\*\\*kwargs : Kwargs Keyword arguments passed to `func`. - + Returns ------- The value returned by `func`. @@ -1573,3 +1576,8 @@ def gen_alignment_data(dtype=float32, type='binary', max_size=24): (o, o + 1, o, s - 1, dtype, 'aliased') yield inp1()[:-1], inp1()[:-1], inp2()[1:], bfmt % \ (o, o, o + 1, s - 1, dtype, 'aliased') + + +class IgnoreException(Exception): + "Ignoring this exception due to disabled feature" + |