mirror of
https://github.com/boostorg/python.git
synced 2026-01-21 05:02:17 +00:00
untabify python test files
This commit is contained in:
@@ -6,45 +6,45 @@ import indexing_mod
|
||||
|
||||
class TestIndexing(unittest.TestCase):
|
||||
|
||||
def testSingle(self):
|
||||
x = numpy.arange(0,10)
|
||||
for i in range(0,10):
|
||||
numpy.testing.assert_equal(indexing_mod.single(x,i), i)
|
||||
for i in range(-10,0):
|
||||
numpy.testing.assert_equal(indexing_mod.single(x,i),10+i)
|
||||
def testSingle(self):
|
||||
x = numpy.arange(0,10)
|
||||
for i in range(0,10):
|
||||
numpy.testing.assert_equal(indexing_mod.single(x,i), i)
|
||||
for i in range(-10,0):
|
||||
numpy.testing.assert_equal(indexing_mod.single(x,i),10+i)
|
||||
|
||||
def testSlice(self):
|
||||
x = numpy.arange(0,10)
|
||||
sl = slice(3,8)
|
||||
b = [3,4,5,6,7]
|
||||
numpy.testing.assert_equal(indexing_mod.slice(x,sl), b)
|
||||
def testSlice(self):
|
||||
x = numpy.arange(0,10)
|
||||
sl = slice(3,8)
|
||||
b = [3,4,5,6,7]
|
||||
numpy.testing.assert_equal(indexing_mod.slice(x,sl), b)
|
||||
|
||||
def testStepSlice(self):
|
||||
x = numpy.arange(0,10)
|
||||
sl = slice(3,8,2)
|
||||
b = [3,5,7]
|
||||
numpy.testing.assert_equal(indexing_mod.slice(x,sl), b)
|
||||
def testStepSlice(self):
|
||||
x = numpy.arange(0,10)
|
||||
sl = slice(3,8,2)
|
||||
b = [3,5,7]
|
||||
numpy.testing.assert_equal(indexing_mod.slice(x,sl), b)
|
||||
|
||||
def testIndex(self):
|
||||
x = numpy.arange(0,10)
|
||||
chk = numpy.array([3,4,5,6])
|
||||
numpy.testing.assert_equal(indexing_mod.indexarray(x,chk),chk)
|
||||
chk = numpy.array([[0,1],[2,3]])
|
||||
numpy.testing.assert_equal(indexing_mod.indexarray(x,chk),chk)
|
||||
x = numpy.arange(9).reshape(3,3)
|
||||
y = numpy.array([0,1])
|
||||
z = numpy.array([0,2])
|
||||
chk = numpy.array([0,5])
|
||||
numpy.testing.assert_equal(indexing_mod.indexarray(x,y,z),chk)
|
||||
x = numpy.arange(0,10)
|
||||
b = x>4
|
||||
chk = numpy.array([5,6,7,8,9])
|
||||
numpy.testing.assert_equal(indexing_mod.indexarray(x,b),chk)
|
||||
x = numpy.arange(9).reshape(3,3)
|
||||
b = numpy.array([0,2])
|
||||
sl = slice(0,3)
|
||||
chk = numpy.array([[0,1,2],[6,7,8]])
|
||||
numpy.testing.assert_equal(indexing_mod.indexslice(x,b,sl),chk)
|
||||
def testIndex(self):
|
||||
x = numpy.arange(0,10)
|
||||
chk = numpy.array([3,4,5,6])
|
||||
numpy.testing.assert_equal(indexing_mod.indexarray(x,chk),chk)
|
||||
chk = numpy.array([[0,1],[2,3]])
|
||||
numpy.testing.assert_equal(indexing_mod.indexarray(x,chk),chk)
|
||||
x = numpy.arange(9).reshape(3,3)
|
||||
y = numpy.array([0,1])
|
||||
z = numpy.array([0,2])
|
||||
chk = numpy.array([0,5])
|
||||
numpy.testing.assert_equal(indexing_mod.indexarray(x,y,z),chk)
|
||||
x = numpy.arange(0,10)
|
||||
b = x>4
|
||||
chk = numpy.array([5,6,7,8,9])
|
||||
numpy.testing.assert_equal(indexing_mod.indexarray(x,b),chk)
|
||||
x = numpy.arange(9).reshape(3,3)
|
||||
b = numpy.array([0,2])
|
||||
sl = slice(0,3)
|
||||
chk = numpy.array([[0,1,2],[6,7,8]])
|
||||
numpy.testing.assert_equal(indexing_mod.indexslice(x,b,sl),chk)
|
||||
|
||||
if __name__=="__main__":
|
||||
unittest.main()
|
||||
unittest.main()
|
||||
|
||||
@@ -5,60 +5,60 @@ import unittest
|
||||
import numpy
|
||||
|
||||
class TestNdarray(unittest.TestCase):
|
||||
|
||||
def testNdzeros(self):
|
||||
for dtp in (numpy.int16, numpy.int32, numpy.float32, numpy.complex128):
|
||||
v = numpy.zeros(60, dtype=dtp)
|
||||
dt = numpy.dtype(dtp)
|
||||
for shape in ((60,),(6,10),(4,3,5),(2,2,3,5)):
|
||||
a1 = ndarray_mod.zeros(shape,dt)
|
||||
a2 = v.reshape(a1.shape)
|
||||
self.assertEqual(shape,a1.shape)
|
||||
self.assert_((a1 == a2).all())
|
||||
|
||||
def testNdzeros(self):
|
||||
for dtp in (numpy.int16, numpy.int32, numpy.float32, numpy.complex128):
|
||||
v = numpy.zeros(60, dtype=dtp)
|
||||
dt = numpy.dtype(dtp)
|
||||
for shape in ((60,),(6,10),(4,3,5),(2,2,3,5)):
|
||||
a1 = ndarray_mod.zeros(shape,dt)
|
||||
a2 = v.reshape(a1.shape)
|
||||
self.assertEqual(shape,a1.shape)
|
||||
self.assert_((a1 == a2).all())
|
||||
|
||||
def testNdarray(self):
|
||||
a = range(0,60)
|
||||
for dtp in (numpy.int16, numpy.int32, numpy.float32, numpy.complex128):
|
||||
v = numpy.array(a, dtype=dtp)
|
||||
dt = numpy.dtype(dtp)
|
||||
a1 = ndarray_mod.array(a)
|
||||
a2 = ndarray_mod.array(a,dt)
|
||||
self.assert_((a1 == v).all())
|
||||
self.assert_((a2 == v).all())
|
||||
for shape in ((60,),(6,10),(4,3,5),(2,2,3,5)):
|
||||
a1 = a1.reshape(shape)
|
||||
self.assertEqual(shape,a1.shape)
|
||||
a2 = a2.reshape(shape)
|
||||
self.assertEqual(shape,a2.shape)
|
||||
def testNdarray(self):
|
||||
a = range(0,60)
|
||||
for dtp in (numpy.int16, numpy.int32, numpy.float32, numpy.complex128):
|
||||
v = numpy.array(a, dtype=dtp)
|
||||
dt = numpy.dtype(dtp)
|
||||
a1 = ndarray_mod.array(a)
|
||||
a2 = ndarray_mod.array(a,dt)
|
||||
self.assert_((a1 == v).all())
|
||||
self.assert_((a2 == v).all())
|
||||
for shape in ((60,),(6,10),(4,3,5),(2,2,3,5)):
|
||||
a1 = a1.reshape(shape)
|
||||
self.assertEqual(shape,a1.shape)
|
||||
a2 = a2.reshape(shape)
|
||||
self.assertEqual(shape,a2.shape)
|
||||
|
||||
def testNdempty(self):
|
||||
for dtp in (numpy.int16, numpy.int32, numpy.float32, numpy.complex128):
|
||||
dt = numpy.dtype(dtp)
|
||||
for shape in ((60,),(6,10),(4,3,5),(2,2,3,5)):
|
||||
a1 = ndarray_mod.empty(shape,dt)
|
||||
a2 = ndarray_mod.c_empty(shape,dt)
|
||||
self.assertEqual(shape,a1.shape)
|
||||
self.assertEqual(shape,a2.shape)
|
||||
def testNdempty(self):
|
||||
for dtp in (numpy.int16, numpy.int32, numpy.float32, numpy.complex128):
|
||||
dt = numpy.dtype(dtp)
|
||||
for shape in ((60,),(6,10),(4,3,5),(2,2,3,5)):
|
||||
a1 = ndarray_mod.empty(shape,dt)
|
||||
a2 = ndarray_mod.c_empty(shape,dt)
|
||||
self.assertEqual(shape,a1.shape)
|
||||
self.assertEqual(shape,a2.shape)
|
||||
|
||||
def testTranspose(self):
|
||||
for dtp in (numpy.int16, numpy.int32, numpy.float32, numpy.complex128):
|
||||
dt = numpy.dtype(dtp)
|
||||
for shape in ((6,10),(4,3,5),(2,2,3,5)):
|
||||
a1 = numpy.empty(shape,dt)
|
||||
a2 = a1.transpose()
|
||||
a1 = ndarray_mod.transpose(a1)
|
||||
self.assertEqual(a1.shape,a2.shape)
|
||||
def testTranspose(self):
|
||||
for dtp in (numpy.int16, numpy.int32, numpy.float32, numpy.complex128):
|
||||
dt = numpy.dtype(dtp)
|
||||
for shape in ((6,10),(4,3,5),(2,2,3,5)):
|
||||
a1 = numpy.empty(shape,dt)
|
||||
a2 = a1.transpose()
|
||||
a1 = ndarray_mod.transpose(a1)
|
||||
self.assertEqual(a1.shape,a2.shape)
|
||||
|
||||
def testSqueeze(self):
|
||||
a1 = numpy.array([[[3,4,5]]])
|
||||
a2 = a1.squeeze()
|
||||
a1 = ndarray_mod.squeeze(a1)
|
||||
self.assertEqual(a1.shape,a2.shape)
|
||||
def testSqueeze(self):
|
||||
a1 = numpy.array([[[3,4,5]]])
|
||||
a2 = a1.squeeze()
|
||||
a1 = ndarray_mod.squeeze(a1)
|
||||
self.assertEqual(a1.shape,a2.shape)
|
||||
|
||||
def testReshape(self):
|
||||
a1 = numpy.empty((2,2))
|
||||
a2 = ndarray_mod.reshape(a1,(1,4))
|
||||
self.assertEqual(a2.shape,(1,4))
|
||||
def testReshape(self):
|
||||
a1 = numpy.empty((2,2))
|
||||
a2 = ndarray_mod.reshape(a1,(1,4))
|
||||
self.assertEqual(a2.shape,(1,4))
|
||||
|
||||
if __name__=="__main__":
|
||||
unittest.main()
|
||||
unittest.main()
|
||||
|
||||
@@ -5,12 +5,12 @@ import unittest
|
||||
import numpy
|
||||
|
||||
class TestShapes(unittest.TestCase):
|
||||
|
||||
def testShapes(self):
|
||||
a1 = numpy.array([(0,1),(2,3)])
|
||||
a1_shape = (1,4)
|
||||
a1 = shapes_mod.reshape(a1,a1_shape)
|
||||
self.assertEqual(a1_shape,a1.shape)
|
||||
|
||||
def testShapes(self):
|
||||
a1 = numpy.array([(0,1),(2,3)])
|
||||
a1_shape = (1,4)
|
||||
a1 = shapes_mod.reshape(a1,a1_shape)
|
||||
self.assertEqual(a1_shape,a1.shape)
|
||||
|
||||
if __name__=="__main__":
|
||||
unittest.main()
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user