summaryrefslogtreecommitdiff
path: root/numpy/lib/tests
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/lib/tests')
-rw-r--r--numpy/lib/tests/test__datasource.py14
-rw-r--r--numpy/lib/tests/test_arraysetops.py26
-rw-r--r--numpy/lib/tests/test_financial.py7
-rw-r--r--numpy/lib/tests/test_format.py4
-rw-r--r--numpy/lib/tests/test_function_base.py163
-rw-r--r--numpy/lib/tests/test_getlimits.py28
-rw-r--r--numpy/lib/tests/test_index_tricks.py19
-rw-r--r--numpy/lib/tests/test_io.py9
-rw-r--r--numpy/lib/tests/test_machar.py7
-rw-r--r--numpy/lib/tests/test_polynomial.py14
-rw-r--r--numpy/lib/tests/test_regression.py4
-rw-r--r--numpy/lib/tests/test_shape_base.py175
-rw-r--r--numpy/lib/tests/test_twodim_base.py46
-rw-r--r--numpy/lib/tests/test_type_check.py127
-rw-r--r--numpy/lib/tests/test_ufunclike.py8
15 files changed, 352 insertions, 299 deletions
diff --git a/numpy/lib/tests/test__datasource.py b/numpy/lib/tests/test__datasource.py
index 93e77d28c..695da0470 100644
--- a/numpy/lib/tests/test__datasource.py
+++ b/numpy/lib/tests/test__datasource.py
@@ -67,7 +67,7 @@ def valid_httpfile():
def invalid_httpfile():
return http_fakefile
-class TestDataSourceOpen(NumpyTestCase):
+class TestDataSourceOpen(TestCase):
def setUp(self):
self.tmpdir = mkdtemp()
self.ds = datasource.DataSource(self.tmpdir)
@@ -127,7 +127,7 @@ class TestDataSourceOpen(NumpyTestCase):
self.assertEqual(magic_line, result)
-class TestDataSourceExists(NumpyTestCase):
+class TestDataSourceExists(TestCase):
def setUp(self):
self.tmpdir = mkdtemp()
self.ds = datasource.DataSource(self.tmpdir)
@@ -157,7 +157,7 @@ class TestDataSourceExists(NumpyTestCase):
self.assertEqual(self.ds.exists(tmpfile), False)
-class TestDataSourceAbspath(NumpyTestCase):
+class TestDataSourceAbspath(TestCase):
def setUp(self):
self.tmpdir = os.path.abspath(mkdtemp())
self.ds = datasource.DataSource(self.tmpdir)
@@ -222,7 +222,7 @@ class TestDataSourceAbspath(NumpyTestCase):
os.sep = orig_os_sep
-class TestRepositoryAbspath(NumpyTestCase):
+class TestRepositoryAbspath(TestCase):
def setUp(self):
self.tmpdir = os.path.abspath(mkdtemp())
self.repos = datasource.Repository(valid_baseurl(), self.tmpdir)
@@ -255,7 +255,7 @@ class TestRepositoryAbspath(NumpyTestCase):
os.sep = orig_os_sep
-class TestRepositoryExists(NumpyTestCase):
+class TestRepositoryExists(TestCase):
def setUp(self):
self.tmpdir = mkdtemp()
self.repos = datasource.Repository(valid_baseurl(), self.tmpdir)
@@ -288,7 +288,7 @@ class TestRepositoryExists(NumpyTestCase):
assert self.repos.exists(tmpfile)
-class TestOpenFunc(NumpyTestCase):
+class TestOpenFunc(TestCase):
def setUp(self):
self.tmpdir = mkdtemp()
@@ -304,4 +304,4 @@ class TestOpenFunc(NumpyTestCase):
if __name__ == "__main__":
- NumpyTest().run()
+ nose.run(argv=['', __file__])
diff --git a/numpy/lib/tests/test_arraysetops.py b/numpy/lib/tests/test_arraysetops.py
index 5a5a8fbd8..ca505e9c5 100644
--- a/numpy/lib/tests/test_arraysetops.py
+++ b/numpy/lib/tests/test_arraysetops.py
@@ -6,15 +6,14 @@ from numpy.testing import *
set_package_path()
import numpy
from numpy.lib.arraysetops import *
-from numpy.lib.arraysetops import ediff1d
restore_path()
##################################################
-class TestAso(NumpyTestCase):
+class TestAso(TestCase):
##
# 03.11.2005, c
- def check_unique1d( self ):
+ def test_unique1d( self ):
a = numpy.array( [5, 7, 1, 2, 1, 5, 7] )
@@ -26,7 +25,7 @@ class TestAso(NumpyTestCase):
##
# 03.11.2005, c
- def check_intersect1d( self ):
+ def test_intersect1d( self ):
a = numpy.array( [5, 7, 1, 2] )
b = numpy.array( [2, 4, 3, 1, 5] )
@@ -39,7 +38,7 @@ class TestAso(NumpyTestCase):
##
# 03.11.2005, c
- def check_intersect1d_nu( self ):
+ def test_intersect1d_nu( self ):
a = numpy.array( [5, 5, 7, 1, 2] )
b = numpy.array( [2, 1, 4, 3, 3, 1, 5] )
@@ -52,7 +51,7 @@ class TestAso(NumpyTestCase):
##
# 03.11.2005, c
- def check_setxor1d( self ):
+ def test_setxor1d( self ):
a = numpy.array( [5, 7, 1, 2] )
b = numpy.array( [2, 4, 3, 1, 5] )
@@ -77,7 +76,7 @@ class TestAso(NumpyTestCase):
assert_array_equal([], setxor1d([],[]))
- def check_ediff1d(self):
+ def test_ediff1d(self):
zero_elem = numpy.array([])
one_elem = numpy.array([1])
two_elem = numpy.array([1,2])
@@ -91,7 +90,7 @@ class TestAso(NumpyTestCase):
##
# 03.11.2005, c
- def check_setmember1d( self ):
+ def test_setmember1d( self ):
a = numpy.array( [5, 7, 1, 2] )
b = numpy.array( [2, 4, 3, 1, 5] )
@@ -114,7 +113,7 @@ class TestAso(NumpyTestCase):
##
# 03.11.2005, c
- def check_union1d( self ):
+ def test_union1d( self ):
a = numpy.array( [5, 4, 7, 1, 2] )
b = numpy.array( [2, 4, 3, 3, 2, 1, 5] )
@@ -128,7 +127,7 @@ class TestAso(NumpyTestCase):
##
# 03.11.2005, c
# 09.01.2006
- def check_setdiff1d( self ):
+ def test_setdiff1d( self ):
a = numpy.array( [6, 5, 4, 7, 1, 2] )
b = numpy.array( [2, 4, 3, 3, 2, 1, 5] )
@@ -145,14 +144,14 @@ class TestAso(NumpyTestCase):
assert_array_equal([], setdiff1d([],[]))
- def check_setdiff1d_char_array(self):
+ def test_setdiff1d_char_array(self):
a = numpy.array(['a','b','c'])
b = numpy.array(['a','b','s'])
assert_array_equal(setdiff1d(a,b),numpy.array(['c']))
##
# 03.11.2005, c
- def check_manyways( self ):
+ def test_manyways( self ):
nItem = 100
a = numpy.fix( nItem / 10 * numpy.random.random( nItem ) )
@@ -171,5 +170,6 @@ class TestAso(NumpyTestCase):
c2 = setdiff1d( aux2, aux1 )
assert_array_equal( c1, c2 )
+
if __name__ == "__main__":
- NumpyTest().run()
+ nose.run(argv=['', __file__])
diff --git a/numpy/lib/tests/test_financial.py b/numpy/lib/tests/test_financial.py
index ee38c10dc..df5a0fbde 100644
--- a/numpy/lib/tests/test_financial.py
+++ b/numpy/lib/tests/test_financial.py
@@ -32,8 +32,9 @@ True
from numpy.testing import *
import numpy as np
-class TestDocs(NumpyTestCase):
- def check_doctests(self): return self.rundocs()
+def test():
+ import doctest
+ doctest.testmod()
if __name__ == "__main__":
- NumpyTest().run()
+ nose.run(argv=['', __file__])
diff --git a/numpy/lib/tests/test_format.py b/numpy/lib/tests/test_format.py
index e7b27ce94..4a473c55e 100644
--- a/numpy/lib/tests/test_format.py
+++ b/numpy/lib/tests/test_format.py
@@ -506,3 +506,7 @@ def test_read_version_1_0_bad_magic():
for magic in bad_version_magic + malformed_magic:
f = StringIO(magic)
yield raises(ValueError)(format.read_array), f
+
+
+if __name__ == "__main__":
+ nose.run(argv=['', __file__])
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py
index e1a7ae67a..3cd7cd6bb 100644
--- a/numpy/lib/tests/test_function_base.py
+++ b/numpy/lib/tests/test_function_base.py
@@ -5,11 +5,10 @@ set_package_path()
import numpy.lib;reload(numpy.lib)
from numpy.lib import *
from numpy.core import *
+restore_path()
-del sys.path[0]
-
-class TestAny(NumpyTestCase):
- def check_basic(self):
+class TestAny(TestCase):
+ def test_basic(self):
y1 = [0,0,1,0]
y2 = [0,0,0,0]
y3 = [1,0,1,0]
@@ -17,14 +16,14 @@ class TestAny(NumpyTestCase):
assert(any(y3))
assert(not any(y2))
- def check_nd(self):
+ def test_nd(self):
y1 = [[0,0,0],[0,1,0],[1,1,0]]
assert(any(y1))
assert_array_equal(sometrue(y1,axis=0),[1,1,0])
assert_array_equal(sometrue(y1,axis=1),[0,1,1])
-class TestAll(NumpyTestCase):
- def check_basic(self):
+class TestAll(TestCase):
+ def test_basic(self):
y1 = [0,1,1,0]
y2 = [0,0,0,0]
y3 = [1,1,1,1]
@@ -33,14 +32,14 @@ class TestAll(NumpyTestCase):
assert(not all(y2))
assert(all(~array(y2)))
- def check_nd(self):
+ def test_nd(self):
y1 = [[0,0,1],[0,1,1],[1,1,1]]
assert(not all(y1))
assert_array_equal(alltrue(y1,axis=0),[0,0,1])
assert_array_equal(alltrue(y1,axis=1),[0,0,1])
-class TestAverage(NumpyTestCase):
- def check_basic(self):
+class TestAverage(TestCase):
+ def test_basic(self):
y1 = array([1,2,3])
assert(average(y1,axis=0) == 2.)
y2 = array([1.,2.,3.])
@@ -61,7 +60,7 @@ class TestAverage(NumpyTestCase):
y6 = matrix(rand(5,5))
assert_array_equal(y6.mean(0), average(y6,0))
- def check_weights(self):
+ def test_weights(self):
y = arange(10)
w = arange(10)
assert_almost_equal(average(y, weights=w), (arange(10)**2).sum()*1./arange(10).sum())
@@ -89,7 +88,7 @@ class TestAverage(NumpyTestCase):
assert_equal(average(y1, weights=w2), 5.)
- def check_returned(self):
+ def test_returned(self):
y = array([[1,2,3],[4,5,6]])
# No weights
@@ -116,14 +115,14 @@ class TestAverage(NumpyTestCase):
assert_array_equal(scl, array([1.,6.]))
-class TestSelect(NumpyTestCase):
+class TestSelect(TestCase):
def _select(self,cond,values,default=0):
output = []
for m in range(len(cond)):
output += [V[m] for V,C in zip(values,cond) if C[m]] or [default]
return output
- def check_basic(self):
+ def test_basic(self):
choices = [array([1,2,3]),
array([4,5,6]),
array([7,8,9])]
@@ -136,8 +135,8 @@ class TestSelect(NumpyTestCase):
assert_equal(len(choices),3)
assert_equal(len(conditions),3)
-class TestLogspace(NumpyTestCase):
- def check_basic(self):
+class TestLogspace(TestCase):
+ def test_basic(self):
y = logspace(0,6)
assert(len(y)==50)
y = logspace(0,6,num=100)
@@ -147,8 +146,8 @@ class TestLogspace(NumpyTestCase):
y = logspace(0,6,num=7)
assert_array_equal(y,[1,10,100,1e3,1e4,1e5,1e6])
-class TestLinspace(NumpyTestCase):
- def check_basic(self):
+class TestLinspace(TestCase):
+ def test_basic(self):
y = linspace(0,10)
assert(len(y)==50)
y = linspace(2,10,num=100)
@@ -159,28 +158,28 @@ class TestLinspace(NumpyTestCase):
assert_almost_equal(st,8/49.0)
assert_array_almost_equal(y,mgrid[2:10:50j],13)
- def check_corner(self):
+ def test_corner(self):
y = list(linspace(0,1,1))
assert y == [0.0], y
y = list(linspace(0,1,2.5))
assert y == [0.0, 1.0]
- def check_type(self):
+ def test_type(self):
t1 = linspace(0,1,0).dtype
t2 = linspace(0,1,1).dtype
t3 = linspace(0,1,2).dtype
assert_equal(t1, t2)
assert_equal(t2, t3)
-class TestInsert(NumpyTestCase):
- def check_basic(self):
+class TestInsert(TestCase):
+ def test_basic(self):
a = [1,2,3]
assert_equal(insert(a,0,1), [1,1,2,3])
assert_equal(insert(a,3,1), [1,2,3,1])
assert_equal(insert(a,[1,1,1],[1,2,3]), [1,1,2,3,2,3])
-class TestAmax(NumpyTestCase):
- def check_basic(self):
+class TestAmax(TestCase):
+ def test_basic(self):
a = [3,4,5,10,-3,-5,6.0]
assert_equal(amax(a),10.0)
b = [[3,6.0, 9.0],
@@ -189,8 +188,8 @@ class TestAmax(NumpyTestCase):
assert_equal(amax(b,axis=0),[8.0,10.0,9.0])
assert_equal(amax(b,axis=1),[9.0,10.0,8.0])
-class TestAmin(NumpyTestCase):
- def check_basic(self):
+class TestAmin(TestCase):
+ def test_basic(self):
a = [3,4,5,10,-3,-5,6.0]
assert_equal(amin(a),-5.0)
b = [[3,6.0, 9.0],
@@ -199,8 +198,8 @@ class TestAmin(NumpyTestCase):
assert_equal(amin(b,axis=0),[3.0,3.0,2.0])
assert_equal(amin(b,axis=1),[3.0,4.0,2.0])
-class TestPtp(NumpyTestCase):
- def check_basic(self):
+class TestPtp(TestCase):
+ def test_basic(self):
a = [3,4,5,10,-3,-5,6.0]
assert_equal(ptp(a,axis=0),15.0)
b = [[3,6.0, 9.0],
@@ -209,8 +208,8 @@ class TestPtp(NumpyTestCase):
assert_equal(ptp(b,axis=0),[5.0,7.0,7.0])
assert_equal(ptp(b,axis=-1),[6.0,6.0,6.0])
-class TestCumsum(NumpyTestCase):
- def check_basic(self):
+class TestCumsum(TestCase):
+ def test_basic(self):
ba = [1,2,10,11,6,5,4]
ba2 = [[1,2,3,4],[5,6,7,9],[10,3,4,5]]
for ctype in [int8,uint8,int16,uint16,int32,uint32,
@@ -225,8 +224,8 @@ class TestCumsum(NumpyTestCase):
[5,11,18,27],
[10,13,17,22]],ctype))
-class TestProd(NumpyTestCase):
- def check_basic(self):
+class TestProd(TestCase):
+ def test_basic(self):
ba = [1,2,10,11,6,5,4]
ba2 = [[1,2,3,4],[5,6,7,9],[10,3,4,5]]
for ctype in [int16,uint16,int32,uint32,
@@ -243,8 +242,8 @@ class TestProd(NumpyTestCase):
array([50,36,84,180],ctype))
assert_array_equal(prod(a2,axis=-1),array([24, 1890, 600],ctype))
-class TestCumprod(NumpyTestCase):
- def check_basic(self):
+class TestCumprod(TestCase):
+ def test_basic(self):
ba = [1,2,10,11,6,5,4]
ba2 = [[1,2,3,4],[5,6,7,9],[10,3,4,5]]
for ctype in [int16,uint16,int32,uint32,
@@ -268,8 +267,8 @@ class TestCumprod(NumpyTestCase):
[ 5, 30, 210, 1890],
[10, 30, 120, 600]],ctype))
-class TestDiff(NumpyTestCase):
- def check_basic(self):
+class TestDiff(TestCase):
+ def test_basic(self):
x = [1,4,6,7,12]
out = array([3,2,1,5])
out2 = array([-1,-1,4])
@@ -278,7 +277,7 @@ class TestDiff(NumpyTestCase):
assert_array_equal(diff(x,n=2),out2)
assert_array_equal(diff(x,n=3),out3)
- def check_nd(self):
+ def test_nd(self):
x = 20*rand(10,20,30)
out1 = x[:,:,1:] - x[:,:,:-1]
out2 = out1[:,:,1:] - out1[:,:,:-1]
@@ -289,8 +288,8 @@ class TestDiff(NumpyTestCase):
assert_array_equal(diff(x,axis=0),out3)
assert_array_equal(diff(x,n=2,axis=0),out4)
-class TestAngle(NumpyTestCase):
- def check_basic(self):
+class TestAngle(TestCase):
+ def test_basic(self):
x = [1+3j,sqrt(2)/2.0+1j*sqrt(2)/2,1,1j,-1,-1j,1-3j,-1+3j]
y = angle(x)
yo = [arctan(3.0/1.0),arctan(1.0),0,pi/2,pi,-pi/2.0,
@@ -300,33 +299,33 @@ class TestAngle(NumpyTestCase):
assert_array_almost_equal(y,yo,11)
assert_array_almost_equal(z,zo,11)
-class TestTrimZeros(NumpyTestCase):
+class TestTrimZeros(TestCase):
""" only testing for integer splits.
"""
- def check_basic(self):
+ def test_basic(self):
a= array([0,0,1,2,3,4,0])
res = trim_zeros(a)
assert_array_equal(res,array([1,2,3,4]))
- def check_leading_skip(self):
+ def test_leading_skip(self):
a= array([0,0,1,0,2,3,4,0])
res = trim_zeros(a)
assert_array_equal(res,array([1,0,2,3,4]))
- def check_trailing_skip(self):
+ def test_trailing_skip(self):
a= array([0,0,1,0,2,3,0,4,0])
res = trim_zeros(a)
assert_array_equal(res,array([1,0,2,3,0,4]))
-class TestExtins(NumpyTestCase):
- def check_basic(self):
+class TestExtins(TestCase):
+ def test_basic(self):
a = array([1,3,2,1,2,3,3])
b = extract(a>1,a)
assert_array_equal(b,[3,2,2,3,3])
- def check_place(self):
+ def test_place(self):
a = array([1,4,3,2,5,8,7])
place(a,[0,1,0,1,0,1,0],[2,4,6])
assert_array_equal(a,[1,2,3,4,5,6,7])
- def check_both(self):
+ def test_both(self):
a = rand(10)
mask = a > 0.5
ac = a.copy()
@@ -335,8 +334,8 @@ class TestExtins(NumpyTestCase):
place(a,mask,c)
assert_array_equal(a,ac)
-class TestVectorize(NumpyTestCase):
- def check_simple(self):
+class TestVectorize(TestCase):
+ def test_simple(self):
def addsubtract(a,b):
if a > b:
return a - b
@@ -345,7 +344,7 @@ class TestVectorize(NumpyTestCase):
f = vectorize(addsubtract)
r = f([0,3,6,9],[1,3,5,7])
assert_array_equal(r,[1,6,1,2])
- def check_scalar(self):
+ def test_scalar(self):
def addsubtract(a,b):
if a > b:
return a - b
@@ -354,59 +353,59 @@ class TestVectorize(NumpyTestCase):
f = vectorize(addsubtract)
r = f([0,3,6,9],5)
assert_array_equal(r,[5,8,1,4])
- def check_large(self):
+ def test_large(self):
x = linspace(-3,2,10000)
f = vectorize(lambda x: x)
y = f(x)
assert_array_equal(y, x)
-class TestDigitize(NumpyTestCase):
- def check_forward(self):
+class TestDigitize(TestCase):
+ def test_forward(self):
x = arange(-6,5)
bins = arange(-5,5)
assert_array_equal(digitize(x,bins),arange(11))
- def check_reverse(self):
+ def test_reverse(self):
x = arange(5,-6,-1)
bins = arange(5,-5,-1)
assert_array_equal(digitize(x,bins),arange(11))
- def check_random(self):
+ def test_random(self):
x = rand(10)
bin = linspace(x.min(), x.max(), 10)
assert all(digitize(x,bin) != 0)
-class TestUnwrap(NumpyTestCase):
- def check_simple(self):
+class TestUnwrap(TestCase):
+ def test_simple(self):
#check that unwrap removes jumps greather that 2*pi
assert_array_equal(unwrap([1,1+2*pi]),[1,1])
#check that unwrap maintans continuity
assert(all(diff(unwrap(rand(10)*100))<pi))
-class TestFilterwindows(NumpyTestCase):
- def check_hanning(self):
+class TestFilterwindows(TestCase):
+ def test_hanning(self):
#check symmetry
w=hanning(10)
assert_array_almost_equal(w,flipud(w),7)
#check known value
assert_almost_equal(sum(w,axis=0),4.500,4)
- def check_hamming(self):
+ def test_hamming(self):
#check symmetry
w=hamming(10)
assert_array_almost_equal(w,flipud(w),7)
#check known value
assert_almost_equal(sum(w,axis=0),4.9400,4)
- def check_bartlett(self):
+ def test_bartlett(self):
#check symmetry
w=bartlett(10)
assert_array_almost_equal(w,flipud(w),7)
#check known value
assert_almost_equal(sum(w,axis=0),4.4444,4)
- def check_blackman(self):
+ def test_blackman(self):
#check symmetry
w=blackman(10)
assert_array_almost_equal(w,flipud(w),7)
@@ -414,23 +413,23 @@ class TestFilterwindows(NumpyTestCase):
assert_almost_equal(sum(w,axis=0),3.7800,4)
-class TestTrapz(NumpyTestCase):
- def check_simple(self):
+class TestTrapz(TestCase):
+ def test_simple(self):
r=trapz(exp(-1.0/2*(arange(-10,10,.1))**2)/sqrt(2*pi),dx=0.1)
#check integral of normal equals 1
assert_almost_equal(sum(r,axis=0),1,7)
-class TestSinc(NumpyTestCase):
- def check_simple(self):
+class TestSinc(TestCase):
+ def test_simple(self):
assert(sinc(0)==1)
w=sinc(linspace(-1,1,100))
#check symmetry
assert_array_almost_equal(w,flipud(w),7)
-class TestHistogram(NumpyTestCase):
+class TestHistogram(TestCase):
import warnings
warnings.simplefilter('ignore', FutureWarning)
- def check_simple(self):
+ def test_simple(self):
n=100
v=rand(n)
(a,b)=histogram(v)
@@ -441,7 +440,7 @@ class TestHistogram(NumpyTestCase):
(a,b)=histogram(linspace(0,10,100))
assert_array_equal(a, 10)
- def check_simple_new(self):
+ def test_simple_new(self):
n=100
v=rand(n)
(a,b)=histogram(v, new=True)
@@ -452,7 +451,7 @@ class TestHistogram(NumpyTestCase):
(a,b)=histogram(linspace(0,10,100), new=True)
assert_array_equal(a, 10)
- def check_normed_new(self):
+ def test_normed_new(self):
# Check that the integral of the density equals 1.
n = 100
v = rand(n)
@@ -468,7 +467,7 @@ class TestHistogram(NumpyTestCase):
assert_almost_equal(area, 1)
- def check_outliers_new(self):
+ def test_outliers_new(self):
# Check that outliers are not tallied
a = arange(10)+.5
@@ -493,7 +492,7 @@ class TestHistogram(NumpyTestCase):
assert_equal(h, w[1:-1])
- def check_type_new(self):
+ def test_type_new(self):
# Check the type of the returned histogram
a = arange(10)+.5
h,b = histogram(a, new=True)
@@ -509,7 +508,7 @@ class TestHistogram(NumpyTestCase):
assert(issubdtype(h.dtype, float))
- def check_weights_new(self):
+ def test_weights_new(self):
v = rand(100)
w = ones(100)*5
a,b = histogram(v,new=True)
@@ -531,8 +530,8 @@ class TestHistogram(NumpyTestCase):
wa, wb = histogram([1,2,2,4], bins=4, weights=[4,3,2,1], normed=True, new=True)
assert_array_equal(wa, array([4,5,0,1])/10./3.*4)
-class TestHistogramdd(NumpyTestCase):
- def check_simple(self):
+class TestHistogramdd(TestCase):
+ def test_simple(self):
x = array([[-.5, .5, 1.5], [-.5, 1.5, 2.5], [-.5, 2.5, .5], \
[.5, .5, 1.5], [.5, 1.5, 2.5], [.5, 2.5, 2.5]])
H, edges = histogramdd(x, (2,3,3), range = [[-1,1], [0,3], [0,3]])
@@ -564,7 +563,7 @@ class TestHistogramdd(NumpyTestCase):
H,edges = histogramdd([arange(5), arange(5), arange(5)], 5)
assert_array_equal(H, Z)
- def check_shape_3d(self):
+ def test_shape_3d(self):
# All possible permutations for bins of different lengths in 3D.
bins = ((5, 4, 6), (6, 4, 5), (5, 6, 4), (4, 6, 5), (6, 5, 4),
(4, 5, 6))
@@ -573,7 +572,7 @@ class TestHistogramdd(NumpyTestCase):
H, edges = histogramdd(r, b)
assert(H.shape == b)
- def check_shape_4d(self):
+ def test_shape_4d(self):
# All possible permutations for bins of different lengths in 4D.
bins = ((7, 4, 5, 6), (4, 5, 7, 6), (5, 6, 4, 7), (7, 6, 5, 4),
(5, 7, 6, 4), (4, 6, 7, 5), (6, 5, 7, 4), (7, 5, 4, 6),
@@ -587,7 +586,7 @@ class TestHistogramdd(NumpyTestCase):
H, edges = histogramdd(r, b)
assert(H.shape == b)
- def check_weights(self):
+ def test_weights(self):
v = rand(100,2)
hist, edges = histogramdd(v)
n_hist, edges = histogramdd(v, normed=True)
@@ -598,13 +597,13 @@ class TestHistogramdd(NumpyTestCase):
w_hist, edges = histogramdd(v, weights=ones(100, int)*2)
assert_array_equal(w_hist, 2*hist)
- def check_identical_samples(self):
+ def test_identical_samples(self):
x = zeros((10,2),int)
hist, edges = histogramdd(x, bins=2)
assert_array_equal(edges[0],array([-0.5, 0. , 0.5]))
-class TestUnique(NumpyTestCase):
- def check_simple(self):
+class TestUnique(TestCase):
+ def test_simple(self):
x = array([4,3,2,1,1,2,3,4, 0])
assert(all(unique(x) == [0,1,2,3,4]))
assert(unique(array([1,1,1,1,1])) == array([1]))
@@ -618,4 +617,4 @@ def compare_results(res,desired):
assert_array_equal(res[i],desired[i])
if __name__ == "__main__":
- NumpyTest().run()
+ nose.run(argv=['', __file__])
diff --git a/numpy/lib/tests/test_getlimits.py b/numpy/lib/tests/test_getlimits.py
index a85228689..a6be8abd2 100644
--- a/numpy/lib/tests/test_getlimits.py
+++ b/numpy/lib/tests/test_getlimits.py
@@ -2,39 +2,40 @@
"""
from numpy.testing import *
-import numpy.lib;reload(numpy.lib)
+import numpy.lib
+reload(numpy.lib)
from numpy.lib.getlimits import finfo, iinfo
from numpy import single,double,longdouble
import numpy as np
##################################################
-class TestPythonFloat(NumpyTestCase):
- def check_singleton(self):
+class TestPythonFloat(TestCase):
+ def test_singleton(self):
ftype = finfo(float)
ftype2 = finfo(float)
assert_equal(id(ftype),id(ftype2))
-class TestSingle(NumpyTestCase):
- def check_singleton(self):
+class TestSingle(TestCase):
+ def test_singleton(self):
ftype = finfo(single)
ftype2 = finfo(single)
assert_equal(id(ftype),id(ftype2))
-class TestDouble(NumpyTestCase):
- def check_singleton(self):
+class TestDouble(TestCase):
+ def test_singleton(self):
ftype = finfo(double)
ftype2 = finfo(double)
assert_equal(id(ftype),id(ftype2))
-class TestLongdouble(NumpyTestCase):
- def check_singleton(self,level=2):
+class TestLongdouble(TestCase):
+ def test_singleton(self,level=2):
ftype = finfo(longdouble)
ftype2 = finfo(longdouble)
assert_equal(id(ftype),id(ftype2))
-class TestIinfo(NumpyTestCase):
- def check_basic(self):
+class TestIinfo(TestCase):
+ def test_basic(self):
dts = zip(['i1', 'i2', 'i4', 'i8',
'u1', 'u2', 'u4', 'u8'],
[np.int8, np.int16, np.int32, np.int64,
@@ -44,10 +45,11 @@ class TestIinfo(NumpyTestCase):
assert_equal(iinfo(dt1).max, iinfo(dt2).max)
self.assertRaises(ValueError, iinfo, 'f4')
- def check_unsigned_max(self):
+ def test_unsigned_max(self):
types = np.sctypes['uint']
for T in types:
assert_equal(iinfo(T).max, T(-1))
+
if __name__ == "__main__":
- NumpyTest().run()
+ nose.run(argv=['', __file__])
diff --git a/numpy/lib/tests/test_index_tricks.py b/numpy/lib/tests/test_index_tricks.py
index a0105656b..51d8e59db 100644
--- a/numpy/lib/tests/test_index_tricks.py
+++ b/numpy/lib/tests/test_index_tricks.py
@@ -3,8 +3,8 @@ set_package_path()
from numpy import array, ones, r_, mgrid
restore_path()
-class TestGrid(NumpyTestCase):
- def check_basic(self):
+class TestGrid(TestCase):
+ def test_basic(self):
a = mgrid[-1:1:10j]
b = mgrid[-1:1:0.1]
assert(a.shape == (10,))
@@ -16,7 +16,7 @@ class TestGrid(NumpyTestCase):
assert_almost_equal(b[-1],b[0]+19*0.1,11)
assert_almost_equal(a[1]-a[0],2.0/9.0,11)
- def check_nd(self):
+ def test_nd(self):
c = mgrid[-1:1:10j,-2:2:10j]
d = mgrid[-1:1:0.1,-2:2:0.2]
assert(c.shape == (2,10,10))
@@ -28,22 +28,22 @@ class TestGrid(NumpyTestCase):
assert_array_almost_equal(d[0,1,:]-d[0,0,:], 0.1*ones(20,'d'),11)
assert_array_almost_equal(d[1,:,1]-d[1,:,0], 0.2*ones(20,'d'),11)
-class TestConcatenator(NumpyTestCase):
- def check_1d(self):
+class TestConcatenator(TestCase):
+ def test_1d(self):
assert_array_equal(r_[1,2,3,4,5,6],array([1,2,3,4,5,6]))
b = ones(5)
c = r_[b,0,0,b]
assert_array_equal(c,[1,1,1,1,1,0,0,1,1,1,1,1])
- def check_mixed_type(self):
+ def test_mixed_type(self):
g = r_[10.1, 1:10]
assert(g.dtype == 'f8')
- def check_more_mixed_type(self):
+ def test_more_mixed_type(self):
g = r_[-10.1, array([1]), array([2,3,4]), 10.0]
assert(g.dtype == 'f8')
- def check_2d(self):
+ def test_2d(self):
b = rand(5,5)
c = rand(5,5)
d = r_['1',b,c] # append columns
@@ -55,5 +55,6 @@ class TestConcatenator(NumpyTestCase):
assert_array_equal(d[:5,:],b)
assert_array_equal(d[5:,:],c)
+
if __name__ == "__main__":
- NumpyTest().run()
+ nose.run(argv=['', __file__])
diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py
index 8e7ffc425..7cc595d4f 100644
--- a/numpy/lib/tests/test_io.py
+++ b/numpy/lib/tests/test_io.py
@@ -2,7 +2,7 @@ from numpy.testing import *
import numpy as np
import StringIO
-class TestSaveTxt(NumpyTestCase):
+class TestSaveTxt(TestCase):
def test_array(self):
a =np.array( [[1,2],[3,4]], float)
c = StringIO.StringIO()
@@ -62,7 +62,7 @@ class TestSaveTxt(NumpyTestCase):
assert_equal(lines, ['01 : 2.0\n', '03 : 4.0\n'])
-class TestLoadTxt(NumpyTestCase):
+class TestLoadTxt(TestCase):
def test_record(self):
c = StringIO.StringIO()
c.write('1 2\n3 4')
@@ -164,7 +164,7 @@ class TestLoadTxt(NumpyTestCase):
assert_array_equal(x, a[:,1:])
-class Testfromregex(NumpyTestCase):
+class Testfromregex(TestCase):
def test_record(self):
c = StringIO.StringIO()
c.write('1.312 foo\n1.534 bar\n4.444 qux')
@@ -196,5 +196,6 @@ class Testfromregex(NumpyTestCase):
a = np.array([(1312,), (1534,), (4444,)], dtype=dt)
assert_array_equal(x, a)
+
if __name__ == "__main__":
- NumpyTest().run()
+ nose.run(argv=['', __file__])
diff --git a/numpy/lib/tests/test_machar.py b/numpy/lib/tests/test_machar.py
index 584cd1164..7485fc6c2 100644
--- a/numpy/lib/tests/test_machar.py
+++ b/numpy/lib/tests/test_machar.py
@@ -1,10 +1,10 @@
-from numpy.testing import NumpyTestCase, NumpyTest
+from numpy.testing import *
from numpy.lib.machar import MachAr
import numpy.core.numerictypes as ntypes
from numpy import seterr, array
-class TestMachAr(NumpyTestCase):
+class TestMachAr(TestCase):
def _run_machar_highprec(self):
# Instanciate MachAr instance with high enough precision to cause
# underflow
@@ -26,5 +26,6 @@ class TestMachAr(NumpyTestCase):
finally:
seterr(**serrstate)
+
if __name__ == "__main__":
- NumpyTest().run()
+ nose.run(argv=['', __file__])
diff --git a/numpy/lib/tests/test_polynomial.py b/numpy/lib/tests/test_polynomial.py
index 012f49d77..3bd002cc0 100644
--- a/numpy/lib/tests/test_polynomial.py
+++ b/numpy/lib/tests/test_polynomial.py
@@ -76,13 +76,14 @@ poly1d([ 2.])
from numpy.testing import *
import numpy as np
-class TestDocs(NumpyTestCase):
- def check_doctests(self): return self.rundocs()
+class TestDocs(TestCase):
+ def test_doctests(self):
+ return rundocs()
- def check_roots(self):
+ def test_roots(self):
assert_array_equal(np.roots([1,0,0]), [0,0])
- def check_str_leading_zeros(self):
+ def test_str_leading_zeros(self):
p = np.poly1d([4,3,2,1])
p[3] = 0
assert_equal(str(p),
@@ -94,7 +95,7 @@ class TestDocs(NumpyTestCase):
p[1] = 0
assert_equal(str(p), " \n0")
- def check_polyfit(self) :
+ def test_polyfit(self) :
c = np.array([3., 2., 1.])
x = np.linspace(0,2,5)
y = np.polyval(c,x)
@@ -109,5 +110,6 @@ class TestDocs(NumpyTestCase):
cc = np.concatenate((c,c), axis=1)
assert_almost_equal(cc, np.polyfit(x,yy,2))
+
if __name__ == "__main__":
- NumpyTest().run()
+ nose.run(argv=['', __file__])
diff --git a/numpy/lib/tests/test_regression.py b/numpy/lib/tests/test_regression.py
index 868184b81..a5ba55928 100644
--- a/numpy/lib/tests/test_regression.py
+++ b/numpy/lib/tests/test_regression.py
@@ -6,7 +6,7 @@ restore_path()
rlevel = 1
-class TestRegression(NumpyTestCase):
+class TestRegression(TestCase):
def test_polyfit_build(self,level=rlevel):
"""Ticket #628"""
ref = [-1.06123820e-06, 5.70886914e-04, -1.13822012e-01,
@@ -30,4 +30,4 @@ class TestRegression(NumpyTestCase):
if __name__ == "__main__":
- NumpyTest().run()
+ nose.run(argv=['', __file__])
diff --git a/numpy/lib/tests/test_shape_base.py b/numpy/lib/tests/test_shape_base.py
index 320871a95..60265cd80 100644
--- a/numpy/lib/tests/test_shape_base.py
+++ b/numpy/lib/tests/test_shape_base.py
@@ -1,31 +1,34 @@
from numpy.testing import *
set_package_path()
-import numpy.lib;
from numpy.lib import *
from numpy.core import *
restore_path()
-class TestApplyAlongAxis(NumpyTestCase):
- def check_simple(self):
+class TestApplyAlongAxis(TestCase):
+ def test_simple(self):
a = ones((20,10),'d')
assert_array_equal(apply_along_axis(len,0,a),len(a)*ones(shape(a)[1]))
- def check_simple101(self,level=11):
+
+ def test_simple101(self,level=11):
a = ones((10,101),'d')
assert_array_equal(apply_along_axis(len,0,a),len(a)*ones(shape(a)[1]))
- def check_3d(self):
+ def test_3d(self):
a = arange(27).reshape((3,3,3))
- assert_array_equal(apply_along_axis(sum,0,a), [[27,30,33],[36,39,42],[45,48,51]])
+ assert_array_equal(apply_along_axis(sum,0,a),
+ [[27,30,33],[36,39,42],[45,48,51]])
+
-class TestArraySplit(NumpyTestCase):
- def check_integer_0_split(self):
+class TestArraySplit(TestCase):
+ def test_integer_0_split(self):
a = arange(10)
try:
res = array_split(a,0)
assert(0) # it should have thrown a value error
except ValueError:
pass
- def check_integer_split(self):
+
+ def test_integer_split(self):
a = arange(10)
res = array_split(a,1)
desired = [arange(10)]
@@ -78,19 +81,22 @@ class TestArraySplit(NumpyTestCase):
arange(4,5),arange(5,6), arange(6,7), arange(7,8),
arange(8,9), arange(9,10),array([])]
compare_results(res,desired)
- def check_integer_split_2D_rows(self):
+
+ def test_integer_split_2D_rows(self):
a = array([arange(10),arange(10)])
res = array_split(a,3,axis=0)
desired = [array([arange(10)]),array([arange(10)]),array([])]
compare_results(res,desired)
- def check_integer_split_2D_cols(self):
+
+ def test_integer_split_2D_cols(self):
a = array([arange(10),arange(10)])
res = array_split(a,3,axis=-1)
desired = [array([arange(4),arange(4)]),
array([arange(4,7),arange(4,7)]),
array([arange(7,10),arange(7,10)])]
compare_results(res,desired)
- def check_integer_split_2D_default(self):
+
+ def test_integer_split_2D_default(self):
""" This will fail if we change default axis
"""
a = array([arange(10),arange(10)])
@@ -99,20 +105,21 @@ class TestArraySplit(NumpyTestCase):
compare_results(res,desired)
#perhaps should check higher dimensions
- def check_index_split_simple(self):
+ def test_index_split_simple(self):
a = arange(10)
indices = [1,5,7]
res = array_split(a,indices,axis=-1)
desired = [arange(0,1),arange(1,5),arange(5,7),arange(7,10)]
compare_results(res,desired)
- def check_index_split_low_bound(self):
+ def test_index_split_low_bound(self):
a = arange(10)
indices = [0,5,7]
res = array_split(a,indices,axis=-1)
desired = [array([]),arange(0,5),arange(5,7),arange(7,10)]
compare_results(res,desired)
- def check_index_split_high_bound(self):
+
+ def test_index_split_high_bound(self):
a = arange(10)
indices = [0,5,7,10,12]
res = array_split(a,indices,axis=-1)
@@ -120,18 +127,19 @@ class TestArraySplit(NumpyTestCase):
array([]),array([])]
compare_results(res,desired)
-class TestSplit(NumpyTestCase):
+
+class TestSplit(TestCase):
"""* This function is essentially the same as array_split,
except that it test if splitting will result in an
equal split. Only test for this case.
*"""
- def check_equal_split(self):
+ def test_equal_split(self):
a = arange(10)
res = split(a,2)
desired = [arange(5),arange(5,10)]
compare_results(res,desired)
- def check_unequal_split(self):
+ def test_unequal_split(self):
a = arange(10)
try:
res = split(a,3)
@@ -139,29 +147,34 @@ class TestSplit(NumpyTestCase):
except ValueError:
pass
-class TestAtleast1d(NumpyTestCase):
- def check_0D_array(self):
+
+class TestAtleast1d(TestCase):
+ def test_0D_array(self):
a = array(1); b = array(2);
res=map(atleast_1d,[a,b])
desired = [array([1]),array([2])]
assert_array_equal(res,desired)
- def check_1D_array(self):
+
+ def test_1D_array(self):
a = array([1,2]); b = array([2,3]);
res=map(atleast_1d,[a,b])
desired = [array([1,2]),array([2,3])]
assert_array_equal(res,desired)
- def check_2D_array(self):
+
+ def test_2D_array(self):
a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);
res=map(atleast_1d,[a,b])
desired = [a,b]
assert_array_equal(res,desired)
- def check_3D_array(self):
+
+ def test_3D_array(self):
a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);
a = array([a,a]);b = array([b,b]);
res=map(atleast_1d,[a,b])
desired = [a,b]
assert_array_equal(res,desired)
- def check_r1array(self):
+
+ def test_r1array(self):
""" Test to make sure equivalent Travis O's r1array function
"""
assert(atleast_1d(3).shape == (1,))
@@ -170,114 +183,130 @@ class TestAtleast1d(NumpyTestCase):
assert(atleast_1d(3.0).shape == (1,))
assert(atleast_1d([[2,3],[4,5]]).shape == (2,2))
-class TestAtleast2d(NumpyTestCase):
- def check_0D_array(self):
+class TestAtleast2d(TestCase):
+ def test_0D_array(self):
a = array(1); b = array(2);
res=map(atleast_2d,[a,b])
desired = [array([[1]]),array([[2]])]
assert_array_equal(res,desired)
- def check_1D_array(self):
+
+ def test_1D_array(self):
a = array([1,2]); b = array([2,3]);
res=map(atleast_2d,[a,b])
desired = [array([[1,2]]),array([[2,3]])]
assert_array_equal(res,desired)
- def check_2D_array(self):
+
+ def test_2D_array(self):
a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);
res=map(atleast_2d,[a,b])
desired = [a,b]
assert_array_equal(res,desired)
- def check_3D_array(self):
+
+ def test_3D_array(self):
a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);
a = array([a,a]);b = array([b,b]);
res=map(atleast_2d,[a,b])
desired = [a,b]
assert_array_equal(res,desired)
- def check_r2array(self):
+
+ def test_r2array(self):
""" Test to make sure equivalent Travis O's r2array function
"""
assert(atleast_2d(3).shape == (1,1))
assert(atleast_2d([3j,1]).shape == (1,2))
assert(atleast_2d([[[3,1],[4,5]],[[3,5],[1,2]]]).shape == (2,2,2))
-class TestAtleast3d(NumpyTestCase):
- def check_0D_array(self):
+
+class TestAtleast3d(TestCase):
+ def test_0D_array(self):
a = array(1); b = array(2);
res=map(atleast_3d,[a,b])
desired = [array([[[1]]]),array([[[2]]])]
assert_array_equal(res,desired)
- def check_1D_array(self):
+
+ def test_1D_array(self):
a = array([1,2]); b = array([2,3]);
res=map(atleast_3d,[a,b])
desired = [array([[[1],[2]]]),array([[[2],[3]]])]
assert_array_equal(res,desired)
- def check_2D_array(self):
+
+ def test_2D_array(self):
a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);
res=map(atleast_3d,[a,b])
desired = [a[:,:,newaxis],b[:,:,newaxis]]
assert_array_equal(res,desired)
- def check_3D_array(self):
+
+ def test_3D_array(self):
a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);
a = array([a,a]);b = array([b,b]);
res=map(atleast_3d,[a,b])
desired = [a,b]
assert_array_equal(res,desired)
-class TestHstack(NumpyTestCase):
- def check_0D_array(self):
+class TestHstack(TestCase):
+ def test_0D_array(self):
a = array(1); b = array(2);
res=hstack([a,b])
desired = array([1,2])
assert_array_equal(res,desired)
- def check_1D_array(self):
+
+ def test_1D_array(self):
a = array([1]); b = array([2]);
res=hstack([a,b])
desired = array([1,2])
assert_array_equal(res,desired)
- def check_2D_array(self):
+
+ def test_2D_array(self):
a = array([[1],[2]]); b = array([[1],[2]]);
res=hstack([a,b])
desired = array([[1,1],[2,2]])
assert_array_equal(res,desired)
-class TestVstack(NumpyTestCase):
- def check_0D_array(self):
+class TestVstack(TestCase):
+ def test_0D_array(self):
a = array(1); b = array(2);
res=vstack([a,b])
desired = array([[1],[2]])
assert_array_equal(res,desired)
- def check_1D_array(self):
+
+ def test_1D_array(self):
a = array([1]); b = array([2]);
res=vstack([a,b])
desired = array([[1],[2]])
assert_array_equal(res,desired)
- def check_2D_array(self):
+
+ def test_2D_array(self):
a = array([[1],[2]]); b = array([[1],[2]]);
res=vstack([a,b])
desired = array([[1],[2],[1],[2]])
assert_array_equal(res,desired)
- def check_2D_array2(self):
+
+ def test_2D_array2(self):
a = array([1,2]); b = array([1,2]);
res=vstack([a,b])
desired = array([[1,2],[1,2]])
assert_array_equal(res,desired)
-class TestDstack(NumpyTestCase):
- def check_0D_array(self):
+class TestDstack(TestCase):
+ def test_0D_array(self):
a = array(1); b = array(2);
res=dstack([a,b])
desired = array([[[1,2]]])
assert_array_equal(res,desired)
- def check_1D_array(self):
+
+ def test_1D_array(self):
a = array([1]); b = array([2]);
res=dstack([a,b])
desired = array([[[1,2]]])
assert_array_equal(res,desired)
- def check_2D_array(self):
+
+ def test_2D_array(self):
a = array([[1],[2]]); b = array([[1],[2]]);
res=dstack([a,b])
desired = array([[[1,1]],[[2,2,]]])
assert_array_equal(res,desired)
- def check_2D_array2(self):
+
+ def test_2D_array2(self):
a = array([1,2]); b = array([1,2]);
res=dstack([a,b])
desired = array([[[1,1],[2,2]]])
@@ -286,49 +315,54 @@ class TestDstack(NumpyTestCase):
""" array_split has more comprehensive test of splitting.
only do simple test on hsplit, vsplit, and dsplit
"""
-class TestHsplit(NumpyTestCase):
+class TestHsplit(TestCase):
""" only testing for integer splits.
"""
- def check_0D_array(self):
+ def test_0D_array(self):
a= array(1)
try:
hsplit(a,2)
assert(0)
except ValueError:
pass
- def check_1D_array(self):
+
+ def test_1D_array(self):
a= array([1,2,3,4])
res = hsplit(a,2)
desired = [array([1,2]),array([3,4])]
compare_results(res,desired)
- def check_2D_array(self):
+
+ def test_2D_array(self):
a= array([[1,2,3,4],
[1,2,3,4]])
res = hsplit(a,2)
desired = [array([[1,2],[1,2]]),array([[3,4],[3,4]])]
compare_results(res,desired)
-class TestVsplit(NumpyTestCase):
+
+class TestVsplit(TestCase):
""" only testing for integer splits.
"""
- def check_1D_array(self):
+ def test_1D_array(self):
a= array([1,2,3,4])
try:
vsplit(a,2)
assert(0)
except ValueError:
pass
- def check_2D_array(self):
+
+ def test_2D_array(self):
a= array([[1,2,3,4],
[1,2,3,4]])
res = vsplit(a,2)
desired = [array([[1,2,3,4]]),array([[1,2,3,4]])]
compare_results(res,desired)
-class TestDsplit(NumpyTestCase):
+
+class TestDsplit(TestCase):
""" only testing for integer splits.
"""
- def check_2D_array(self):
+ def test_2D_array(self):
a= array([[1,2,3,4],
[1,2,3,4]])
try:
@@ -336,7 +370,8 @@ class TestDsplit(NumpyTestCase):
assert(0)
except ValueError:
pass
- def check_3D_array(self):
+
+ def test_3D_array(self):
a= array([[[1,2,3,4],
[1,2,3,4]],
[[1,2,3,4],
@@ -346,8 +381,9 @@ class TestDsplit(NumpyTestCase):
array([[[3,4],[3,4]],[[3,4],[3,4]]])]
compare_results(res,desired)
-class TestSqueeze(NumpyTestCase):
- def check_basic(self):
+
+class TestSqueeze(TestCase):
+ def test_basic(self):
a = rand(20,10,10,1,1)
b = rand(20,1,10,1,20)
c = rand(1,1,20,10)
@@ -355,8 +391,9 @@ class TestSqueeze(NumpyTestCase):
assert_array_equal(squeeze(b),reshape(b,(20,10,20)))
assert_array_equal(squeeze(c),reshape(c,(20,10)))
-class TestKron(NumpyTestCase):
- def check_return_type(self):
+
+class TestKron(TestCase):
+ def test_return_type(self):
a = ones([2,2])
m = asmatrix(a)
assert_equal(type(kron(a,a)), ndarray)
@@ -372,8 +409,8 @@ class TestKron(NumpyTestCase):
assert_equal(type(kron(ma,a)), myarray)
-class TestTile(NumpyTestCase):
- def check_basic(self):
+class TestTile(TestCase):
+ def test_basic(self):
a = array([0,1,2])
b = [[1,2],[3,4]]
assert_equal(tile(a,2), [0,1,2,0,1,2])
@@ -384,12 +421,12 @@ class TestTile(NumpyTestCase):
assert_equal(tile(b,(2,2)),[[1,2,1,2],[3,4,3,4],
[1,2,1,2],[3,4,3,4]])
- def check_empty(self):
+ def test_empty(self):
a = array([[[]]])
d = tile(a,(3,2,5)).shape
assert_equal(d,(3,2,0))
- def check_kroncompare(self):
+ def test_kroncompare(self):
import numpy.random as nr
reps=[(2,),(1,2),(2,1),(2,2),(2,3,2),(3,2)]
shape=[(3,),(2,3),(3,4,3),(3,2,3),(4,3,2,4),(2,2)]
@@ -401,12 +438,12 @@ class TestTile(NumpyTestCase):
klarge = kron(a, b)
assert_equal(large, klarge)
-# Utility
+# Utility
def compare_results(res,desired):
for i in range(len(desired)):
assert_array_equal(res[i],desired[i])
if __name__ == "__main__":
- NumpyTest().run()
+ nose.run(argv=['', __file__])
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__])
diff --git a/numpy/lib/tests/test_type_check.py b/numpy/lib/tests/test_type_check.py
index 633c34dc8..80f112427 100644
--- a/numpy/lib/tests/test_type_check.py
+++ b/numpy/lib/tests/test_type_check.py
@@ -10,9 +10,9 @@ restore_path()
def assert_all(x):
assert(all(x)), x
-class TestMintypecode(NumpyTestCase):
+class TestMintypecode(TestCase):
- def check_default_1(self):
+ def test_default_1(self):
for itype in '1bcsuwil':
assert_equal(mintypecode(itype),'d')
assert_equal(mintypecode('f'),'f')
@@ -20,7 +20,7 @@ class TestMintypecode(NumpyTestCase):
assert_equal(mintypecode('F'),'F')
assert_equal(mintypecode('D'),'D')
- def check_default_2(self):
+ def test_default_2(self):
for itype in '1bcsuwil':
assert_equal(mintypecode(itype+'f'),'f')
assert_equal(mintypecode(itype+'d'),'d')
@@ -45,7 +45,7 @@ class TestMintypecode(NumpyTestCase):
assert_equal(mintypecode('DF'),'D')
assert_equal(mintypecode('DD'),'D')
- def check_default_3(self):
+ def test_default_3(self):
assert_equal(mintypecode('fdF'),'D')
#assert_equal(mintypecode('fdF',savespace=1),'F')
assert_equal(mintypecode('fdD'),'D')
@@ -59,8 +59,8 @@ class TestMintypecode(NumpyTestCase):
#assert_equal(mintypecode('idF',savespace=1),'F')
assert_equal(mintypecode('idD'),'D')
-class TestIsscalar(NumpyTestCase):
- def check_basic(self):
+class TestIsscalar(TestCase):
+ def test_basic(self):
assert(isscalar(3))
assert(not isscalar([3]))
assert(not isscalar((3,)))
@@ -68,145 +68,145 @@ class TestIsscalar(NumpyTestCase):
assert(isscalar(10L))
assert(isscalar(4.0))
-class TestReal(NumpyTestCase):
- def check_real(self):
+class TestReal(TestCase):
+ def test_real(self):
y = rand(10,)
assert_array_equal(y,real(y))
- def check_cmplx(self):
+ def test_cmplx(self):
y = rand(10,)+1j*rand(10,)
assert_array_equal(y.real,real(y))
-class TestImag(NumpyTestCase):
- def check_real(self):
+class TestImag(TestCase):
+ def test_real(self):
y = rand(10,)
assert_array_equal(0,imag(y))
- def check_cmplx(self):
+ def test_cmplx(self):
y = rand(10,)+1j*rand(10,)
assert_array_equal(y.imag,imag(y))
-class TestIscomplex(NumpyTestCase):
- def check_fail(self):
+class TestIscomplex(TestCase):
+ def test_fail(self):
z = array([-1,0,1])
res = iscomplex(z)
assert(not sometrue(res,axis=0))
- def check_pass(self):
+ def test_pass(self):
z = array([-1j,1,0])
res = iscomplex(z)
assert_array_equal(res,[1,0,0])
-class TestIsreal(NumpyTestCase):
- def check_pass(self):
+class TestIsreal(TestCase):
+ def test_pass(self):
z = array([-1,0,1j])
res = isreal(z)
assert_array_equal(res,[1,1,0])
- def check_fail(self):
+ def test_fail(self):
z = array([-1j,1,0])
res = isreal(z)
assert_array_equal(res,[0,1,1])
-class TestIscomplexobj(NumpyTestCase):
- def check_basic(self):
+class TestIscomplexobj(TestCase):
+ def test_basic(self):
z = array([-1,0,1])
assert(not iscomplexobj(z))
z = array([-1j,0,-1])
assert(iscomplexobj(z))
-class TestIsrealobj(NumpyTestCase):
- def check_basic(self):
+class TestIsrealobj(TestCase):
+ def test_basic(self):
z = array([-1,0,1])
assert(isrealobj(z))
z = array([-1j,0,-1])
assert(not isrealobj(z))
-class TestIsnan(NumpyTestCase):
- def check_goodvalues(self):
+class TestIsnan(TestCase):
+ def test_goodvalues(self):
z = array((-1.,0.,1.))
res = isnan(z) == 0
assert_all(alltrue(res,axis=0))
- def check_posinf(self):
+ def test_posinf(self):
olderr = seterr(divide='ignore')
assert_all(isnan(array((1.,))/0.) == 0)
seterr(**olderr)
- def check_neginf(self):
+ def test_neginf(self):
olderr = seterr(divide='ignore')
assert_all(isnan(array((-1.,))/0.) == 0)
seterr(**olderr)
- def check_ind(self):
+ def test_ind(self):
olderr = seterr(divide='ignore', invalid='ignore')
assert_all(isnan(array((0.,))/0.) == 1)
seterr(**olderr)
- #def check_qnan(self): log(-1) return pi*j now
+ #def test_qnan(self): log(-1) return pi*j now
# assert_all(isnan(log(-1.)) == 1)
- def check_integer(self):
+ def test_integer(self):
assert_all(isnan(1) == 0)
- def check_complex(self):
+ def test_complex(self):
assert_all(isnan(1+1j) == 0)
- def check_complex1(self):
+ def test_complex1(self):
olderr = seterr(divide='ignore', invalid='ignore')
assert_all(isnan(array(0+0j)/0.) == 1)
seterr(**olderr)
-class TestIsfinite(NumpyTestCase):
- def check_goodvalues(self):
+class TestIsfinite(TestCase):
+ def test_goodvalues(self):
z = array((-1.,0.,1.))
res = isfinite(z) == 1
assert_all(alltrue(res,axis=0))
- def check_posinf(self):
+ def test_posinf(self):
olderr = seterr(divide='ignore')
assert_all(isfinite(array((1.,))/0.) == 0)
seterr(**olderr)
- def check_neginf(self):
+ def test_neginf(self):
olderr = seterr(divide='ignore')
assert_all(isfinite(array((-1.,))/0.) == 0)
seterr(**olderr)
- def check_ind(self):
+ def test_ind(self):
olderr = seterr(divide='ignore', invalid='ignore')
assert_all(isfinite(array((0.,))/0.) == 0)
seterr(**olderr)
- #def check_qnan(self):
+ #def test_qnan(self):
# assert_all(isfinite(log(-1.)) == 0)
- def check_integer(self):
+ def test_integer(self):
assert_all(isfinite(1) == 1)
- def check_complex(self):
+ def test_complex(self):
assert_all(isfinite(1+1j) == 1)
- def check_complex1(self):
+ def test_complex1(self):
olderr = seterr(divide='ignore', invalid='ignore')
assert_all(isfinite(array(1+1j)/0.) == 0)
seterr(**olderr)
-class TestIsinf(NumpyTestCase):
- def check_goodvalues(self):
+class TestIsinf(TestCase):
+ def test_goodvalues(self):
z = array((-1.,0.,1.))
res = isinf(z) == 0
assert_all(alltrue(res,axis=0))
- def check_posinf(self):
+ def test_posinf(self):
olderr = seterr(divide='ignore')
assert_all(isinf(array((1.,))/0.) == 1)
seterr(**olderr)
- def check_posinf_scalar(self):
+ def test_posinf_scalar(self):
olderr = seterr(divide='ignore')
assert_all(isinf(array(1.,)/0.) == 1)
seterr(**olderr)
- def check_neginf(self):
+ def test_neginf(self):
olderr = seterr(divide='ignore')
assert_all(isinf(array((-1.,))/0.) == 1)
seterr(**olderr)
- def check_neginf_scalar(self):
+ def test_neginf_scalar(self):
olderr = seterr(divide='ignore')
assert_all(isinf(array(-1.)/0.) == 1)
seterr(**olderr)
- def check_ind(self):
+ def test_ind(self):
olderr = seterr(divide='ignore', invalid='ignore')
assert_all(isinf(array((0.,))/0.) == 0)
seterr(**olderr)
- #def check_qnan(self):
+ #def test_qnan(self):
# assert_all(isinf(log(-1.)) == 0)
# assert_all(isnan(log(-1.)) == 1)
-class TestIsposinf(NumpyTestCase):
- def check_generic(self):
+class TestIsposinf(TestCase):
+ def test_generic(self):
olderr = seterr(divide='ignore', invalid='ignore')
vals = isposinf(array((-1.,0,1))/0.)
seterr(**olderr)
@@ -214,8 +214,8 @@ class TestIsposinf(NumpyTestCase):
assert(vals[1] == 0)
assert(vals[2] == 1)
-class TestIsneginf(NumpyTestCase):
- def check_generic(self):
+class TestIsneginf(TestCase):
+ def test_generic(self):
olderr = seterr(divide='ignore', invalid='ignore')
vals = isneginf(array((-1.,0,1))/0.)
seterr(**olderr)
@@ -223,21 +223,21 @@ class TestIsneginf(NumpyTestCase):
assert(vals[1] == 0)
assert(vals[2] == 0)
-class TestNanToNum(NumpyTestCase):
- def check_generic(self):
+class TestNanToNum(TestCase):
+ def test_generic(self):
olderr = seterr(divide='ignore', invalid='ignore')
vals = nan_to_num(array((-1.,0,1))/0.)
seterr(**olderr)
assert_all(vals[0] < -1e10) and assert_all(isfinite(vals[0]))
assert(vals[1] == 0)
assert_all(vals[2] > 1e10) and assert_all(isfinite(vals[2]))
- def check_integer(self):
+ def test_integer(self):
vals = nan_to_num(1)
assert_all(vals == 1)
- def check_complex_good(self):
+ def test_complex_good(self):
vals = nan_to_num(1+1j)
assert_all(vals == 1+1j)
- def check_complex_bad(self):
+ def test_complex_bad(self):
v = 1+1j
olderr = seterr(divide='ignore', invalid='ignore')
v += array(0+1.j)/0.
@@ -245,7 +245,7 @@ class TestNanToNum(NumpyTestCase):
vals = nan_to_num(v)
# !! This is actually (unexpectedly) zero
assert_all(isfinite(vals))
- def check_complex_bad2(self):
+ def test_complex_bad2(self):
v = 1+1j
olderr = seterr(divide='ignore', invalid='ignore')
v += array(-1+1.j)/0.
@@ -259,8 +259,8 @@ class TestNanToNum(NumpyTestCase):
#assert_all(vals.real < -1e10) and assert_all(isfinite(vals))
-class TestRealIfClose(NumpyTestCase):
- def check_basic(self):
+class TestRealIfClose(TestCase):
+ def test_basic(self):
a = rand(10)
b = real_if_close(a+1e-15j)
assert_all(isrealobj(b))
@@ -270,11 +270,12 @@ class TestRealIfClose(NumpyTestCase):
b = real_if_close(a+1e-7j,tol=1e-6)
assert_all(isrealobj(b))
-class TestArrayConversion(NumpyTestCase):
- def check_asfarray(self):
+class TestArrayConversion(TestCase):
+ def test_asfarray(self):
a = asfarray(array([1,2,3]))
assert_equal(a.__class__,ndarray)
assert issubdtype(a.dtype,float)
+
if __name__ == "__main__":
- NumpyTest().run()
+ nose.run(argv=['', __file__])
diff --git a/numpy/lib/tests/test_ufunclike.py b/numpy/lib/tests/test_ufunclike.py
index 926439fb4..f734355bd 100644
--- a/numpy/lib/tests/test_ufunclike.py
+++ b/numpy/lib/tests/test_ufunclike.py
@@ -59,8 +59,10 @@ array([ 2.169925 , 1.20163386, 2.70043972])
from numpy.testing import *
-class TestDocs(NumpyTestCase):
- def check_doctests(self): return self.rundocs()
+class TestDocs(TestCase):
+ def test_doctests(self):
+ return rundocs()
+
if __name__ == "__main__":
- NumpyTest().run()
+ nose.run(argv=['', __file__])