File size: 1,424 Bytes
c011401 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
from __future__ import division, absolute_import, print_function
import sys
from numpy.core import arange
from numpy.testing import (
run_module_suite, assert_, assert_equal
)
from numpy.lib import deprecate
import numpy.lib.utils as utils
if sys.version_info[0] >= 3:
from io import StringIO
else:
from StringIO import StringIO
def test_lookfor():
out = StringIO()
utils.lookfor('eigenvalue', module='numpy', output=out,
import_modules=False)
out = out.getvalue()
assert_('numpy.linalg.eig' in out)
@deprecate
def old_func(self, x):
return x
@deprecate(message="Rather use new_func2")
def old_func2(self, x):
return x
def old_func3(self, x):
return x
new_func3 = deprecate(old_func3, old_name="old_func3", new_name="new_func3")
def test_deprecate_decorator():
assert_('deprecated' in old_func.__doc__)
def test_deprecate_decorator_message():
assert_('Rather use new_func2' in old_func2.__doc__)
def test_deprecate_fn():
assert_('old_func3' in new_func3.__doc__)
assert_('new_func3' in new_func3.__doc__)
def test_safe_eval_nameconstant():
# Test if safe_eval supports Python 3.4 _ast.NameConstant
utils.safe_eval('None')
def test_byte_bounds():
a = arange(12).reshape(3, 4)
low, high = utils.byte_bounds(a)
assert_equal(high - low, a.size * a.itemsize)
if __name__ == "__main__":
run_module_suite()
|