Skip to content

Commit

Permalink
MAINT: remove unused and broken parts of numpy.testing
Browse files Browse the repository at this point in the history
Deprecate np.testing.importall - it's pointless and partially broken.
  • Loading branch information
rgommers committed Aug 10, 2013
1 parent 928289b commit d6e8c91
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 47 deletions.
2 changes: 1 addition & 1 deletion numpy/testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

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
2 changes: 1 addition & 1 deletion numpy/testing/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
"""
from __future__ import division, absolute_import, print_function

import sys
import warnings
import collections


def slow(t):
"""
Label a test as 'slow'.
Expand Down
3 changes: 1 addition & 2 deletions numpy/testing/nosetester.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
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.
Expand Down Expand Up @@ -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:
Expand Down
17 changes: 0 additions & 17 deletions numpy/testing/nulltester.py

This file was deleted.

30 changes: 7 additions & 23 deletions numpy/testing/numpytest.py
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
14 changes: 11 additions & 3 deletions numpy/testing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
'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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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`.
Expand Down Expand Up @@ -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"

0 comments on commit d6e8c91

Please sign in to comment.