]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/python/test/numpy/indexing.py
3 # Copyright Jim Bosch & Ankit Daftery 2010-2012.
4 # Distributed under the Boost Software License, Version 1.0.
5 # (See accompanying file LICENSE_1_0.txt or copy at
6 # http://www.boost.org/LICENSE_1_0.txt)
12 class TestIndexing(unittest
.TestCase
):
15 x
= numpy
.arange(0,10)
17 numpy
.testing
.assert_equal(indexing_ext
.single(x
,i
), i
)
18 for i
in range(-10,0):
19 numpy
.testing
.assert_equal(indexing_ext
.single(x
,i
),10+i
)
22 x
= numpy
.arange(0,10)
25 numpy
.testing
.assert_equal(indexing_ext
.slice(x
,sl
), b
)
27 def testStepSlice(self
):
28 x
= numpy
.arange(0,10)
31 numpy
.testing
.assert_equal(indexing_ext
.slice(x
,sl
), b
)
34 x
= numpy
.arange(0,10)
35 chk
= numpy
.array([3,4,5,6])
36 numpy
.testing
.assert_equal(indexing_ext
.indexarray(x
,chk
),chk
)
37 chk
= numpy
.array([[0,1],[2,3]])
38 numpy
.testing
.assert_equal(indexing_ext
.indexarray(x
,chk
),chk
)
39 x
= numpy
.arange(9).reshape(3,3)
40 y
= numpy
.array([0,1])
41 z
= numpy
.array([0,2])
42 chk
= numpy
.array([0,5])
43 numpy
.testing
.assert_equal(indexing_ext
.indexarray(x
,y
,z
),chk
)
44 x
= numpy
.arange(0,10)
46 chk
= numpy
.array([5,6,7,8,9])
47 numpy
.testing
.assert_equal(indexing_ext
.indexarray(x
,b
),chk
)
48 x
= numpy
.arange(9).reshape(3,3)
49 b
= numpy
.array([0,2])
51 chk
= numpy
.array([[0,1,2],[6,7,8]])
52 numpy
.testing
.assert_equal(indexing_ext
.indexslice(x
,b
,sl
),chk
)
54 if __name__
=="__main__":