Hackfut Security File Manager
Current Path:
/opt/alt/python27/lib64/python2.7/site-packages/numpy/core/tests
opt
/
alt
/
python27
/
lib64
/
python2.7
/
site-packages
/
numpy
/
core
/
tests
/
📁
..
📁
data
📄
test_abc.py
(1.97 KB)
📄
test_abc.pyc
(2.69 KB)
📄
test_abc.pyo
(2.69 KB)
📄
test_api.py
(18.41 KB)
📄
test_api.pyc
(15.56 KB)
📄
test_api.pyo
(15.56 KB)
📄
test_arrayprint.py
(6.73 KB)
📄
test_arrayprint.pyc
(10.33 KB)
📄
test_arrayprint.pyo
(10.33 KB)
📄
test_datetime.py
(88.29 KB)
📄
test_datetime.pyc
(60.87 KB)
📄
test_datetime.pyo
(60.87 KB)
📄
test_defchararray.py
(26.28 KB)
📄
test_defchararray.pyc
(39.08 KB)
📄
test_defchararray.pyo
(39.08 KB)
📄
test_deprecations.py
(32.64 KB)
📄
test_deprecations.pyc
(47.97 KB)
📄
test_deprecations.pyo
(47.97 KB)
📄
test_dtype.py
(24.01 KB)
📄
test_dtype.pyc
(26.9 KB)
📄
test_dtype.pyo
(26.9 KB)
📄
test_einsum.py
(25.09 KB)
📄
test_einsum.pyc
(20.42 KB)
📄
test_einsum.pyo
(20.42 KB)
📄
test_errstate.py
(1.55 KB)
📄
test_errstate.pyc
(2.4 KB)
📄
test_errstate.pyo
(2.4 KB)
📄
test_extint128.py
(5.62 KB)
📄
test_extint128.pyc
(7.75 KB)
📄
test_extint128.pyo
(7.75 KB)
📄
test_function_base.py
(5.24 KB)
📄
test_function_base.pyc
(9.45 KB)
📄
test_function_base.pyo
(9.37 KB)
📄
test_getlimits.py
(2.22 KB)
📄
test_getlimits.pyc
(5.31 KB)
📄
test_getlimits.pyo
(5.31 KB)
📄
test_half.py
(18.1 KB)
📄
test_half.pyc
(18.32 KB)
📄
test_half.pyo
(18.32 KB)
📄
test_indexerrors.py
(4.82 KB)
📄
test_indexerrors.pyc
(11.62 KB)
📄
test_indexerrors.pyo
(11.62 KB)
📄
test_indexing.py
(39.93 KB)
📄
test_indexing.pyc
(36.73 KB)
📄
test_indexing.pyo
(36.73 KB)
📄
test_item_selection.py
(3.5 KB)
📄
test_item_selection.pyc
(4.38 KB)
📄
test_item_selection.pyo
(4.38 KB)
📄
test_longdouble.py
(5.71 KB)
📄
test_longdouble.pyc
(10.27 KB)
📄
test_longdouble.pyo
(10.27 KB)
📄
test_machar.py
(1014 B)
📄
test_machar.pyc
(1.71 KB)
📄
test_machar.pyo
(1.71 KB)
📄
test_mem_overlap.py
(15.4 KB)
📄
test_mem_overlap.pyc
(21.25 KB)
📄
test_mem_overlap.pyo
(21.25 KB)
📄
test_memmap.py
(4.2 KB)
📄
test_memmap.pyc
(6.35 KB)
📄
test_memmap.pyo
(6.35 KB)
📄
test_multiarray.py
(235.11 KB)
📄
test_multiarray.pyc
(271.28 KB)
📄
test_multiarray.pyo
(271.25 KB)
📄
test_nditer.py
(101.78 KB)
📄
test_nditer.pyc
(85.59 KB)
📄
test_nditer.pyo
(85.59 KB)
📄
test_numeric.py
(89.25 KB)
📄
test_numeric.pyc
(110.54 KB)
📄
test_numeric.pyo
(110.54 KB)
📄
test_numerictypes.py
(14.38 KB)
📄
test_numerictypes.pyc
(18.27 KB)
📄
test_numerictypes.pyo
(18.27 KB)
📄
test_print.py
(8 KB)
📄
test_print.pyc
(10.02 KB)
📄
test_print.pyo
(10.02 KB)
📄
test_records.py
(13.12 KB)
📄
test_records.pyc
(17.07 KB)
📄
test_records.pyo
(17.07 KB)
📄
test_regression.py
(77.01 KB)
📄
test_regression.pyc
(106.12 KB)
📄
test_regression.pyo
(106.12 KB)
📄
test_scalarinherit.py
(771 B)
📄
test_scalarinherit.pyc
(2.72 KB)
📄
test_scalarinherit.pyo
(2.72 KB)
📄
test_scalarmath.py
(18.65 KB)
📄
test_scalarmath.pyc
(20.1 KB)
📄
test_scalarmath.pyo
(20.1 KB)
📄
test_scalarprint.py
(917 B)
📄
test_scalarprint.pyc
(1.45 KB)
📄
test_scalarprint.pyo
(1.45 KB)
📄
test_shape_base.py
(11.23 KB)
📄
test_shape_base.pyc
(14.63 KB)
📄
test_shape_base.pyo
(14.63 KB)
📄
test_ufunc.py
(49.29 KB)
📄
test_ufunc.pyc
(50.63 KB)
📄
test_ufunc.pyo
(50.63 KB)
📄
test_umath.py
(73.33 KB)
📄
test_umath.pyc
(95.78 KB)
📄
test_umath.pyo
(95.72 KB)
📄
test_umath_complex.py
(19.34 KB)
📄
test_umath_complex.pyc
(19.11 KB)
📄
test_umath_complex.pyo
(19.11 KB)
📄
test_unicode.py
(12.34 KB)
📄
test_unicode.pyc
(16.09 KB)
📄
test_unicode.pyo
(16.09 KB)
Editing: test_shape_base.py
from __future__ import division, absolute_import, print_function import numpy as np from numpy.compat import long from numpy.core import (array, arange, atleast_1d, atleast_2d, atleast_3d, vstack, hstack, newaxis, concatenate, stack) from numpy.testing import (TestCase, assert_, assert_raises, assert_array_equal, assert_equal, run_module_suite, assert_raises_regex) class TestAtleast1d(TestCase): def test_0D_array(self): a = array(1) b = array(2) res = [atleast_1d(a), atleast_1d(b)] desired = [array([1]), array([2])] assert_array_equal(res, desired) def test_1D_array(self): a = array([1, 2]) b = array([2, 3]) res = [atleast_1d(a), atleast_1d(b)] desired = [array([1, 2]), array([2, 3])] assert_array_equal(res, desired) def test_2D_array(self): a = array([[1, 2], [1, 2]]) b = array([[2, 3], [2, 3]]) res = [atleast_1d(a), atleast_1d(b)] desired = [a, b] assert_array_equal(res, desired) 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 = [atleast_1d(a), atleast_1d(b)] desired = [a, b] assert_array_equal(res, desired) def test_r1array(self): """ Test to make sure equivalent Travis O's r1array function """ assert_(atleast_1d(3).shape == (1,)) assert_(atleast_1d(3j).shape == (1,)) assert_(atleast_1d(long(3)).shape == (1,)) assert_(atleast_1d(3.0).shape == (1,)) assert_(atleast_1d([[2, 3], [4, 5]]).shape == (2, 2)) class TestAtleast2d(TestCase): def test_0D_array(self): a = array(1) b = array(2) res = [atleast_2d(a), atleast_2d(b)] desired = [array([[1]]), array([[2]])] assert_array_equal(res, desired) def test_1D_array(self): a = array([1, 2]) b = array([2, 3]) res = [atleast_2d(a), atleast_2d(b)] desired = [array([[1, 2]]), array([[2, 3]])] assert_array_equal(res, desired) def test_2D_array(self): a = array([[1, 2], [1, 2]]) b = array([[2, 3], [2, 3]]) res = [atleast_2d(a), atleast_2d(b)] desired = [a, b] assert_array_equal(res, desired) 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 = [atleast_2d(a), atleast_2d(b)] desired = [a, b] assert_array_equal(res, desired) 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(TestCase): def test_0D_array(self): a = array(1) b = array(2) res = [atleast_3d(a), atleast_3d(b)] desired = [array([[[1]]]), array([[[2]]])] assert_array_equal(res, desired) def test_1D_array(self): a = array([1, 2]) b = array([2, 3]) res = [atleast_3d(a), atleast_3d(b)] desired = [array([[[1], [2]]]), array([[[2], [3]]])] assert_array_equal(res, desired) def test_2D_array(self): a = array([[1, 2], [1, 2]]) b = array([[2, 3], [2, 3]]) res = [atleast_3d(a), atleast_3d(b)] desired = [a[:,:, newaxis], b[:,:, newaxis]] assert_array_equal(res, desired) 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 = [atleast_3d(a), atleast_3d(b)] desired = [a, b] assert_array_equal(res, desired) 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 test_1D_array(self): a = array([1]) b = array([2]) res = hstack([a, b]) desired = array([1, 2]) assert_array_equal(res, desired) 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(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 test_1D_array(self): a = array([1]) b = array([2]) res = vstack([a, b]) desired = array([[1], [2]]) assert_array_equal(res, desired) 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 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 TestConcatenate(TestCase): def test_exceptions(self): # test axis must be in bounds for ndim in [1, 2, 3]: a = np.ones((1,)*ndim) np.concatenate((a, a), axis=0) # OK assert_raises(IndexError, np.concatenate, (a, a), axis=ndim) assert_raises(IndexError, np.concatenate, (a, a), axis=-(ndim + 1)) # Scalars cannot be concatenated assert_raises(ValueError, concatenate, (0,)) assert_raises(ValueError, concatenate, (np.array(0),)) # test shapes must match except for concatenation axis a = np.ones((1, 2, 3)) b = np.ones((2, 2, 3)) axis = list(range(3)) for i in range(3): np.concatenate((a, b), axis=axis[0]) # OK assert_raises(ValueError, np.concatenate, (a, b), axis=axis[1]) assert_raises(ValueError, np.concatenate, (a, b), axis=axis[2]) a = np.rollaxis(a, -1) b = np.rollaxis(b, -1) axis.append(axis.pop(0)) # No arrays to concatenate raises ValueError assert_raises(ValueError, concatenate, ()) def test_concatenate_axis_None(self): a = np.arange(4, dtype=np.float64).reshape((2, 2)) b = list(range(3)) c = ['x'] r = np.concatenate((a, a), axis=None) assert_equal(r.dtype, a.dtype) assert_equal(r.ndim, 1) r = np.concatenate((a, b), axis=None) assert_equal(r.size, a.size + len(b)) assert_equal(r.dtype, a.dtype) r = np.concatenate((a, b, c), axis=None) d = array(['0.0', '1.0', '2.0', '3.0', '0', '1', '2', 'x']) assert_array_equal(r, d) def test_large_concatenate_axis_None(self): # When no axis is given, concatenate uses flattened versions. # This also had a bug with many arrays (see gh-5979). x = np.arange(1, 100) r = np.concatenate(x, None) assert_array_equal(x, r) # This should probably be deprecated: r = np.concatenate(x, 100) # axis is >= MAXDIMS assert_array_equal(x, r) def test_concatenate(self): # Test concatenate function # One sequence returns unmodified (but as array) r4 = list(range(4)) assert_array_equal(concatenate((r4,)), r4) # Any sequence assert_array_equal(concatenate((tuple(r4),)), r4) assert_array_equal(concatenate((array(r4),)), r4) # 1D default concatenation r3 = list(range(3)) assert_array_equal(concatenate((r4, r3)), r4 + r3) # Mixed sequence types assert_array_equal(concatenate((tuple(r4), r3)), r4 + r3) assert_array_equal(concatenate((array(r4), r3)), r4 + r3) # Explicit axis specification assert_array_equal(concatenate((r4, r3), 0), r4 + r3) # Including negative assert_array_equal(concatenate((r4, r3), -1), r4 + r3) # 2D a23 = array([[10, 11, 12], [13, 14, 15]]) a13 = array([[0, 1, 2]]) res = array([[10, 11, 12], [13, 14, 15], [0, 1, 2]]) assert_array_equal(concatenate((a23, a13)), res) assert_array_equal(concatenate((a23, a13), 0), res) assert_array_equal(concatenate((a23.T, a13.T), 1), res.T) assert_array_equal(concatenate((a23.T, a13.T), -1), res.T) # Arrays much match shape assert_raises(ValueError, concatenate, (a23.T, a13.T), 0) # 3D res = arange(2 * 3 * 7).reshape((2, 3, 7)) a0 = res[..., :4] a1 = res[..., 4:6] a2 = res[..., 6:] assert_array_equal(concatenate((a0, a1, a2), 2), res) assert_array_equal(concatenate((a0, a1, a2), -1), res) assert_array_equal(concatenate((a0.T, a1.T, a2.T), 0), res.T) def test_stack(): # 0d input for input_ in [(1, 2, 3), [np.int32(1), np.int32(2), np.int32(3)], [np.array(1), np.array(2), np.array(3)]]: assert_array_equal(stack(input_), [1, 2, 3]) # 1d input examples a = np.array([1, 2, 3]) b = np.array([4, 5, 6]) r1 = array([[1, 2, 3], [4, 5, 6]]) assert_array_equal(np.stack((a, b)), r1) assert_array_equal(np.stack((a, b), axis=1), r1.T) # all input types assert_array_equal(np.stack(list([a, b])), r1) assert_array_equal(np.stack(array([a, b])), r1) # all shapes for 1d input arrays = [np.random.randn(3) for _ in range(10)] axes = [0, 1, -1, -2] expected_shapes = [(10, 3), (3, 10), (3, 10), (10, 3)] for axis, expected_shape in zip(axes, expected_shapes): assert_equal(np.stack(arrays, axis).shape, expected_shape) assert_raises_regex(IndexError, 'out of bounds', stack, arrays, axis=2) assert_raises_regex(IndexError, 'out of bounds', stack, arrays, axis=-3) # all shapes for 2d input arrays = [np.random.randn(3, 4) for _ in range(10)] axes = [0, 1, 2, -1, -2, -3] expected_shapes = [(10, 3, 4), (3, 10, 4), (3, 4, 10), (3, 4, 10), (3, 10, 4), (10, 3, 4)] for axis, expected_shape in zip(axes, expected_shapes): assert_equal(np.stack(arrays, axis).shape, expected_shape) # empty arrays assert_(stack([[], [], []]).shape == (3, 0)) assert_(stack([[], [], []], axis=1).shape == (0, 3)) # edge cases assert_raises_regex(ValueError, 'need at least one array', stack, []) assert_raises_regex(ValueError, 'must have the same shape', stack, [1, np.arange(3)]) assert_raises_regex(ValueError, 'must have the same shape', stack, [np.arange(3), 1]) assert_raises_regex(ValueError, 'must have the same shape', stack, [np.arange(3), 1], axis=1) assert_raises_regex(ValueError, 'must have the same shape', stack, [np.zeros((3, 3)), np.zeros(3)], axis=1) assert_raises_regex(ValueError, 'must have the same shape', stack, [np.arange(2), np.arange(3)]) # np.matrix m = np.matrix([[1, 2], [3, 4]]) assert_raises_regex(ValueError, 'shape too large to be a matrix', stack, [m, m]) if __name__ == "__main__": run_module_suite()
Upload File
Create Folder