/
usr
/
lib64
/
python2.6
/
site-packages
/
numpy
/
lib
/
tests
/
/usr/lib64/python2.6/site-packages/numpy/lib/tests
mkdir
upload
Name
Size
Mode
Actions
test_arraysetops.py
6993
0644
edit
dl
rm
test_arraysetops.pyc
7760
0644
edit
dl
rm
test_arraysetops.pyo
7760
0644
edit
dl
rm
test_arrayterator.py
1315
0644
edit
dl
rm
test_arrayterator.pyc
1964
0644
edit
dl
rm
test_arrayterator.pyo
1710
0644
edit
dl
rm
test_financial.py
1911
0644
edit
dl
rm
test_financial.pyc
3683
0644
edit
dl
rm
test_financial.pyo
3683
0644
edit
dl
rm
test_format.py
25312
0644
edit
dl
rm
test_format.pyc
25261
0644
edit
dl
rm
test_format.pyo
25236
0644
edit
dl
rm
test_function_base.py
31443
0644
edit
dl
rm
test_function_base.pyc
43457
0644
edit
dl
rm
test_function_base.pyo
42029
0644
edit
dl
rm
test_index_tricks.py
3928
0644
edit
dl
rm
test_index_tricks.pyc
7125
0644
edit
dl
rm
test_index_tricks.pyo
6529
0644
edit
dl
rm
test_io.py
44958
0644
edit
dl
rm
test_io.pyc
58173
0644
edit
dl
rm
test_io.pyo
57879
0644
edit
dl
rm
test_polynomial.py
3566
0644
edit
dl
rm
test_polynomial.pyc
5303
0644
edit
dl
rm
test_polynomial.pyo
4728
0644
edit
dl
rm
test_recfunctions.py
24942
0644
edit
dl
rm
test_recfunctions.pyc
29895
0644
edit
dl
rm
test_recfunctions.pyo
29813
0644
edit
dl
rm
test_regression.py
6357
0644
edit
dl
rm
test_regression.pyc
11069
0644
edit
dl
rm
test_regression.pyo
10974
0644
edit
dl
rm
test_shape_base.py
9945
0644
edit
dl
rm
test_shape_base.pyc
16188
0644
edit
dl
rm
test_shape_base.pyo
16059
0644
edit
dl
rm
test_stride_tricks.py
6958
0644
edit
dl
rm
test_stride_tricks.pyc
9183
0644
edit
dl
rm
test_stride_tricks.pyo
9144
0644
edit
dl
rm
test_twodim_base.py
10185
0644
edit
dl
rm
test_twodim_base.pyc
14005
0644
edit
dl
rm
test_twodim_base.pyo
14005
0644
edit
dl
rm
test_type_check.py
9579
0644
edit
dl
rm
test_type_check.pyc
18846
0644
edit
dl
rm
test_type_check.pyo
18044
0644
edit
dl
rm
test_ufunclike.py
1776
0644
edit
dl
rm
test_ufunclike.pyc
2129
0644
edit
dl
rm
test_ufunclike.pyo
2129
0644
edit
dl
rm
test_utils.py
910
0644
edit
dl
rm
test_utils.pyc
2211
0644
edit
dl
rm
test_utils.pyo
1955
0644
edit
dl
rm
test__datasource.py
9921
0644
edit
dl
rm
test__datasource.pyc
16260
0644
edit
dl
rm
test__datasource.pyo
15403
0644
edit
dl
rm
test__iotools.py
10899
0644
edit
dl
rm
test__iotools.pyc
12397
0644
edit
dl
rm
test__iotools.pyo
12305
0644
edit
dl
rm
Edit:
/usr/lib64/python2.6/site-packages/numpy/lib/tests/test_index_tricks.py
(3928B)
from numpy.testing import * import numpy as np from numpy import ( array, ones, r_, mgrid, unravel_index, zeros, where, ndenumerate, fill_diagonal, diag_indices, diag_indices_from ) class TestUnravelIndex(TestCase): def test_basic(self): assert unravel_index(2,(2,2)) == (1,0) assert unravel_index(254,(17,94)) == (2, 66) assert_raises(ValueError, unravel_index, 4,(2,2)) class TestGrid(TestCase): def test_basic(self): a = mgrid[-1:1:10j] b = mgrid[-1:1:0.1] assert(a.shape == (10,)) assert(b.shape == (20,)) assert(a[0] == -1) assert_almost_equal(a[-1],1) assert(b[0] == -1) assert_almost_equal(b[1]-b[0],0.1,11) assert_almost_equal(b[-1],b[0]+19*0.1,11) assert_almost_equal(a[1]-a[0],2.0/9.0,11) def test_linspace_equivalence(self): y,st = np.linspace(2,10,retstep=1) assert_almost_equal(st,8/49.0) assert_array_almost_equal(y,mgrid[2:10:50j],13) 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)) assert(d.shape == (2,20,20)) assert_array_equal(c[0][0,:],-ones(10,'d')) assert_array_equal(c[1][:,0],-2*ones(10,'d')) assert_array_almost_equal(c[0][-1,:],ones(10,'d'),11) assert_array_almost_equal(c[1][:,-1],2*ones(10,'d'),11) 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(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 test_mixed_type(self): g = r_[10.1, 1:10] assert(g.dtype == 'f8') def test_more_mixed_type(self): g = r_[-10.1, array([1]), array([2,3,4]), 10.0] assert(g.dtype == 'f8') def test_2d(self): b = rand(5,5) c = rand(5,5) d = r_['1',b,c] # append columns assert(d.shape == (5,10)) assert_array_equal(d[:,:5],b) assert_array_equal(d[:,5:],c) d = r_[b,c] assert(d.shape == (10,5)) assert_array_equal(d[:5,:],b) assert_array_equal(d[5:,:],c) class TestNdenumerate(TestCase): def test_basic(self): a = array([[1,2], [3,4]]) assert_equal(list(ndenumerate(a)), [((0,0), 1), ((0,1), 2), ((1,0), 3), ((1,1), 4)]) def test_fill_diagonal(): a = zeros((3, 3),int) fill_diagonal(a, 5) yield (assert_array_equal, a, array([[5, 0, 0], [0, 5, 0], [0, 0, 5]])) # The same function can operate on a 4-d array: a = zeros((3, 3, 3, 3), int) fill_diagonal(a, 4) i = array([0, 1, 2]) yield (assert_equal, where(a != 0), (i, i, i, i)) def test_diag_indices(): di = diag_indices(4) a = array([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]) a[di] = 100 yield (assert_array_equal, a, array([[100, 2, 3, 4], [ 5, 100, 7, 8], [ 9, 10, 100, 12], [ 13, 14, 15, 100]])) # Now, we create indices to manipulate a 3-d array: d3 = diag_indices(2, 3) # And use it to set the diagonal of a zeros array to 1: a = zeros((2, 2, 2),int) a[d3] = 1 yield (assert_array_equal, a, array([[[1, 0], [0, 0]], [[0, 0], [0, 1]]]) ) def test_diag_indices_from(): x = np.random.random((4, 4)) r, c = diag_indices_from(x) assert_array_equal(r, np.arange(4)) assert_array_equal(c, np.arange(4)) if __name__ == "__main__": run_module_suite()
Save
cmd:
run