summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_twodim_base.py
diff options
context:
space:
mode:
authorAlan McIntyre <alan.mcintyre@local>2008-06-17 00:23:20 +0000
committerAlan McIntyre <alan.mcintyre@local>2008-06-17 00:23:20 +0000
commitc331857d8663ecf54bbe88c834755da749e8ab52 (patch)
treef4cc69ec328a5ff4d3b108f3610acb119a196493 /numpy/lib/tests/test_twodim_base.py
parent22ba7886a84dc6a16ca75871f7cd2f10ef8de1f9 (diff)
downloadnumpy-c331857d8663ecf54bbe88c834755da749e8ab52.tar.gz
Switched to use nose to run tests. Added test and bench functions to all modules.
Diffstat (limited to 'numpy/lib/tests/test_twodim_base.py')
-rw-r--r--numpy/lib/tests/test_twodim_base.py46
1 files changed, 24 insertions, 22 deletions
diff --git a/numpy/lib/tests/test_twodim_base.py b/numpy/lib/tests/test_twodim_base.py
index 3a9e8df80..33a685bcf 100644
--- a/numpy/lib/tests/test_twodim_base.py
+++ b/numpy/lib/tests/test_twodim_base.py
@@ -17,8 +17,8 @@ def get_mat(n):
data = add.outer(data,data)
return data
-class TestEye(NumpyTestCase):
- def check_basic(self):
+class TestEye(TestCase):
+ def test_basic(self):
assert_equal(eye(4),array([[1,0,0,0],
[0,1,0,0],
[0,0,1,0],
@@ -29,7 +29,7 @@ class TestEye(NumpyTestCase):
[0,0,0,1]],'f'))
assert_equal(eye(3) == 1, eye(3,dtype=bool))
- def check_diag(self):
+ def test_diag(self):
assert_equal(eye(4,k=1),array([[0,1,0,0],
[0,0,1,0],
[0,0,0,1],
@@ -38,7 +38,7 @@ class TestEye(NumpyTestCase):
[1,0,0,0],
[0,1,0,0],
[0,0,1,0]]))
- def check_2d(self):
+ def test_2d(self):
assert_equal(eye(4,3),array([[1,0,0],
[0,1,0],
[0,0,1],
@@ -46,7 +46,7 @@ class TestEye(NumpyTestCase):
assert_equal(eye(3,4),array([[1,0,0,0],
[0,1,0,0],
[0,0,1,0]]))
- def check_diag2d(self):
+ def test_diag2d(self):
assert_equal(eye(3,4,k=2),array([[0,0,1,0],
[0,0,0,1],
[0,0,0,0]]))
@@ -55,8 +55,8 @@ class TestEye(NumpyTestCase):
[1,0,0],
[0,1,0]]))
-class TestDiag(NumpyTestCase):
- def check_vector(self):
+class TestDiag(TestCase):
+ def test_vector(self):
vals = (100*arange(5)).astype('l')
b = zeros((5,5))
for k in range(5):
@@ -70,7 +70,7 @@ class TestDiag(NumpyTestCase):
assert_equal(diag(vals,k=2), b)
assert_equal(diag(vals,k=-2), c)
- def check_matrix(self):
+ def test_matrix(self):
vals = (100*get_mat(5)+1).astype('l')
b = zeros((5,))
for k in range(5):
@@ -84,8 +84,8 @@ class TestDiag(NumpyTestCase):
b[k] = vals[k+2,k]
assert_equal(diag(vals,-2),b[:3])
-class TestFliplr(NumpyTestCase):
- def check_basic(self):
+class TestFliplr(TestCase):
+ def test_basic(self):
self.failUnlessRaises(ValueError, fliplr, ones(4))
a = get_mat(4)
b = a[:,::-1]
@@ -96,8 +96,8 @@ class TestFliplr(NumpyTestCase):
[5,4,3]]
assert_equal(fliplr(a),b)
-class TestFlipud(NumpyTestCase):
- def check_basic(self):
+class TestFlipud(TestCase):
+ def test_basic(self):
a = get_mat(4)
b = a[::-1,:]
assert_equal(flipud(a),b)
@@ -107,8 +107,8 @@ class TestFlipud(NumpyTestCase):
[0,1,2]]
assert_equal(flipud(a),b)
-class TestRot90(NumpyTestCase):
- def check_basic(self):
+class TestRot90(TestCase):
+ def test_basic(self):
self.failUnlessRaises(ValueError, rot90, ones(4))
a = [[0,1,2],
@@ -133,12 +133,12 @@ class TestRot90(NumpyTestCase):
for k in range(0,13,4):
assert_equal(rot90(a,k=k),b4)
- def check_axes(self):
+ def test_axes(self):
a = ones((50,40,3))
assert_equal(rot90(a).shape,(40,50,3))
-class TestHistogram2d(NumpyTestCase):
- def check_simple(self):
+class TestHistogram2d(TestCase):
+ def test_simple(self):
x = array([ 0.41702200, 0.72032449, 0.00011437481, 0.302332573, 0.146755891])
y = array([ 0.09233859, 0.18626021, 0.34556073, 0.39676747, 0.53881673])
xedges = np.linspace(0,1,10)
@@ -161,7 +161,7 @@ class TestHistogram2d(NumpyTestCase):
assert_array_equal(xedges, np.linspace(0,9,11))
assert_array_equal(yedges, np.linspace(0,9,11))
- def check_asym(self):
+ def test_asym(self):
x = array([1, 1, 2, 3, 4, 4, 4, 5])
y = array([1, 3, 2, 0, 1, 2, 3, 4])
H, xed, yed = histogram2d(x,y, (6, 5), range = [[0,6],[0,5]], normed=True)
@@ -174,7 +174,7 @@ class TestHistogram2d(NumpyTestCase):
assert_array_almost_equal(H, answer/8., 3)
assert_array_equal(xed, np.linspace(0,6,7))
assert_array_equal(yed, np.linspace(0,5,6))
- def check_norm(self):
+ def test_norm(self):
x = array([1,2,3,1,2,3,1,2,3])
y = array([1,1,1,2,2,2,3,3,3])
H, xed, yed = histogram2d(x,y,[[1,2,3,5], [1,2,3,5]], normed=True)
@@ -183,12 +183,13 @@ class TestHistogram2d(NumpyTestCase):
[.5,.5,.25]])/9.
assert_array_almost_equal(H, answer, 3)
- def check_all_outliers(self):
+ def test_all_outliers(self):
r = rand(100)+1.
H, xed, yed = histogram2d(r, r, (4, 5), range=([0,1], [0,1]))
assert_array_equal(H, 0)
-class TestTri(NumpyTestCase):
+
+class TestTri(TestCase):
def test_dtype(self):
out = array([[1,0,0],
[1,1,0],
@@ -196,5 +197,6 @@ class TestTri(NumpyTestCase):
assert_array_equal(tri(3),out)
assert_array_equal(tri(3,dtype=bool),out.astype(bool))
+
if __name__ == "__main__":
- NumpyTest().run()
+ nose.run(argv=['', __file__])