Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/mingw32/Python27/Lib/site-packages/numpy/lib/tests/test_utils.py @ 87:2a2c65a20a8b
Add Python libs and headers
author | Chris Cannam |
---|---|
date | Wed, 25 Feb 2015 14:05:22 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
86:413a9d26189e | 87:2a2c65a20a8b |
---|---|
1 from __future__ import division, absolute_import, print_function | |
2 | |
3 import sys | |
4 from numpy.core import arange | |
5 from numpy.testing import ( | |
6 run_module_suite, assert_, assert_equal, dec | |
7 ) | |
8 from numpy.lib import deprecate | |
9 import numpy.lib.utils as utils | |
10 | |
11 if sys.version_info[0] >= 3: | |
12 from io import StringIO | |
13 else: | |
14 from StringIO import StringIO | |
15 | |
16 | |
17 @dec.skipif(sys.flags.optimize == 2) | |
18 def test_lookfor(): | |
19 out = StringIO() | |
20 utils.lookfor('eigenvalue', module='numpy', output=out, | |
21 import_modules=False) | |
22 out = out.getvalue() | |
23 assert_('numpy.linalg.eig' in out) | |
24 | |
25 | |
26 @deprecate | |
27 def old_func(self, x): | |
28 return x | |
29 | |
30 | |
31 @deprecate(message="Rather use new_func2") | |
32 def old_func2(self, x): | |
33 return x | |
34 | |
35 | |
36 def old_func3(self, x): | |
37 return x | |
38 new_func3 = deprecate(old_func3, old_name="old_func3", new_name="new_func3") | |
39 | |
40 | |
41 def test_deprecate_decorator(): | |
42 assert_('deprecated' in old_func.__doc__) | |
43 | |
44 | |
45 def test_deprecate_decorator_message(): | |
46 assert_('Rather use new_func2' in old_func2.__doc__) | |
47 | |
48 | |
49 def test_deprecate_fn(): | |
50 assert_('old_func3' in new_func3.__doc__) | |
51 assert_('new_func3' in new_func3.__doc__) | |
52 | |
53 | |
54 def test_safe_eval_nameconstant(): | |
55 # Test if safe_eval supports Python 3.4 _ast.NameConstant | |
56 utils.safe_eval('None') | |
57 | |
58 | |
59 def test_byte_bounds(): | |
60 a = arange(12).reshape(3, 4) | |
61 low, high = utils.byte_bounds(a) | |
62 assert_equal(high - low, a.size * a.itemsize) | |
63 | |
64 | |
65 if __name__ == "__main__": | |
66 run_module_suite() |