Skip to content

Commit da8e309

Browse files
author
nobody
committed
This commit was manufactured by cvs2svn to create branch 'RC_1_34_0'.
[SVN r35598]
1 parent 2bd9141 commit da8e309

3 files changed

Lines changed: 115 additions & 0 deletions

File tree

test/numarray_tests.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Copyright David Abrahams 2006. Distributed under the Boost
2+
# Software License, Version 1.0. (See accompanying
3+
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
4+
import printer
5+
6+
# So we can coerce portably across Python versions
7+
bool = type(1 == 1)
8+
9+
'''
10+
>>> from numpy_ext import *
11+
>>> x = new_array()
12+
>>> y = x.copy()
13+
>>> p = _printer()
14+
>>> check = p.check
15+
>>> exercise_numarray(x, p)
16+
17+
>>> check(str(y))
18+
19+
>>> check(y.argmax());
20+
>>> check(y.argmax(0));
21+
22+
>>> check(y.argmin());
23+
>>> check(y.argmin(0));
24+
25+
>>> check(y.argsort());
26+
>>> check(y.argsort(1));
27+
28+
>>> y.byteswap();
29+
>>> check(y);
30+
31+
>>> check(y.diagonal());
32+
>>> check(y.diagonal(1));
33+
>>> check(y.diagonal(0, 0));
34+
>>> check(y.diagonal(0, 1, 0));
35+
36+
>>> check(y.is_c_array());
37+
38+
# coerce because numarray still returns an int and the C++ interface forces
39+
# the return type to bool
40+
>>> check( bool(y.isbyteswapped()) );
41+
42+
>>> check(y.trace());
43+
>>> check(y.trace(1));
44+
>>> check(y.trace(0, 0));
45+
>>> check(y.trace(0, 1, 0));
46+
47+
>>> check(y.new('D').getshape());
48+
>>> check(y.new('D').type());
49+
>>> y.sort();
50+
>>> check(y);
51+
>>> check(y.type());
52+
53+
>>> check(y.factory((1.2, 3.4)));
54+
>>> check(y.factory((1.2, 3.4), "f8"))
55+
>>> check(y.factory((1.2, 3.4), "f8", true))
56+
>>> check(y.factory((1.2, 3.4), "f8", true, false))
57+
>>> check(y.factory((1.2, 3.4), "f8", true, false, None))
58+
>>> check(y.factory((1.2, 3.4), "f8", true, false, None, (1,2,1)))
59+
60+
>>> p.results
61+
[]
62+
>>> del p
63+
'''

test/numeric_tests.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Copyright David Abrahams 2006. Distributed under the Boost
2+
# Software License, Version 1.0. (See accompanying
3+
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
4+
import printer
5+
'''
6+
>>> from numpy_ext import *
7+
>>> x = new_array()
8+
>>> x[1,1] = 0.0
9+
10+
>>> try: take_array(3)
11+
... except TypeError: pass
12+
... else: print 'expected a TypeError'
13+
14+
>>> take_array(x)
15+
16+
>>> print x
17+
[[1 2 3]
18+
[4 0 6]
19+
[7 8 9]]
20+
21+
>>> y = x.copy()
22+
23+
24+
>>> p = _printer()
25+
>>> check = p.check
26+
>>> exercise(x, p)
27+
>>> y[2,1] = 3
28+
>>> check(y);
29+
30+
>>> check(y.astype('D'));
31+
32+
>>> check(y.copy());
33+
34+
>>> check(y.typecode());
35+
36+
>>> p.results
37+
[]
38+
>>> del p
39+
'''

test/printer.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright David Abrahams 2006. Distributed under the Boost
2+
# Software License, Version 1.0. (See accompanying
3+
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
4+
class _printer(object):
5+
def __init__(self):
6+
self.results = [];
7+
def __call__(self, *stuff):
8+
for x in stuff:
9+
self.results.append(str(x))
10+
def check(self, x):
11+
if self.results[0] != str(x):
12+
print ' Expected:\n %s\n but the C++ interface gave:\n %s' % (x, self.results[0])
13+
del self.results[0]

0 commit comments

Comments
 (0)