[pypy-commit] pypy default: remove old test_lib_pypy tests of numpypy
bdkearns
noreply at buildbot.pypy.org
Fri Dec 5 21:19:56 CET 2014
Author: Brian Kearns <bdkearns at gmail.com>
Branch:
Changeset: r74840:0123a8ee6ab6
Date: 2014-12-05 15:16 -0500
http://bitbucket.org/pypy/pypy/changeset/0123a8ee6ab6/
Log: remove old test_lib_pypy tests of numpypy
diff --git a/pypy/module/test_lib_pypy/numpypy/__init__.py b/pypy/module/test_lib_pypy/numpypy/__init__.py
deleted file mode 100644
diff --git a/pypy/module/test_lib_pypy/numpypy/core/test_fromnumeric.py b/pypy/module/test_lib_pypy/numpypy/core/test_fromnumeric.py
deleted file mode 100644
--- a/pypy/module/test_lib_pypy/numpypy/core/test_fromnumeric.py
+++ /dev/null
@@ -1,202 +0,0 @@
-from pypy.module.test_lib_pypy.numpypy.test_base import BaseNumpyAppTest
-
-
-class AppTestFromNumeric(BaseNumpyAppTest):
- def test_argmax(self):
- # tests taken from numpy/core/fromnumeric.py docstring
- from numpypy import arange, argmax
- a = arange(6).reshape((2,3))
- assert argmax(a) == 5
- # assert (argmax(a, axis=0) == array([1, 1, 1])).all()
- # assert (argmax(a, axis=1) == array([2, 2])).all()
- b = arange(6)
- b[1] = 5
- assert argmax(b) == 1
-
- def test_argmin(self):
- # tests adapted from test_argmax
- from numpypy import arange, argmin
- a = arange(6).reshape((2,3))
- assert argmin(a) == 0
- #assert (argmin(a, axis=0) == array([0, 0, 0])).all()
- #assert (argmin(a, axis=1) == array([0, 0])).all()
- b = arange(6)
- b[1] = 0
- assert argmin(b) == 0
-
- def test_ravel(self):
- import numpypy as np
- a = np.ravel(np.float64(1))
- assert np.array_equal(a, [1.])
- a = np.ravel(np.array([[1, 2, 3], [4, 5, 6]]))
- assert np.array_equal(a, [1, 2, 3, 4, 5, 6])
-
- def test_shape(self):
- # tests taken from numpy/core/fromnumeric.py docstring
- from numpypy import identity, shape
- assert shape(identity(3)) == (3, 3)
- assert shape([[1, 2]]) == (1, 2)
- assert shape([0]) == (1,)
- assert shape(0) == ()
- # a = array([(1, 2), (3, 4)], dtype=[('x', 'i4'), ('y', 'i4')])
- # assert shape(a) == (2,)
-
- def test_clip(self):
- import numpypy as np
- a = np.arange(10)
- b = np.clip(a, 1, 8)
- assert (b == [1, 1, 2, 3, 4, 5, 6, 7, 8, 8]).all()
- assert (a == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]).all()
- b = np.clip(a, 3, 6, out=a)
- assert (b == [3, 3, 3, 3, 4, 5, 6, 6, 6, 6]).all()
- assert (a == [3, 3, 3, 3, 4, 5, 6, 6, 6, 6]).all()
- a = np.arange(10)
- b = np.clip(a, [3,4,1,1,1,4,4,4,4,4], 8)
- assert (b == [3, 4, 2, 3, 4, 5, 6, 7, 8, 8]).all()
- assert (a == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]).all()
-
- def test_sum(self):
- # tests taken from numpy/core/fromnumeric.py docstring
- from numpypy import sum, ones, zeros, array
- assert sum([0.5, 1.5])== 2.0
- assert sum([[0, 1], [0, 5]]) == 6
- # assert sum([0.5, 0.7, 0.2, 1.5], dtype=int32) == 1
- assert (sum([[0, 1], [0, 5]], axis=0) == array([0, 6])).all()
- assert (sum([[0, 1], [0, 5]], axis=1) == array([1, 5])).all()
- # If the accumulator is too small, overflow occurs:
- # assert ones(128, dtype=int8).sum(dtype=int8) == -128
-
- assert sum(range(10)) == 45
- assert sum(array(range(10))) == 45
- assert list(sum(zeros((0, 2)), axis=1)) == []
-
- a = array([[1, 2], [3, 4]])
- out = array([[0, 0], [0, 0]])
- c = sum(a, axis=0, out=out[0])
- assert (c == [4, 6]).all()
- assert (c == out[0]).all()
- assert (c != out[1]).all()
-
- def test_amin(self):
- # tests taken from numpy/core/fromnumeric.py docstring
- from numpypy import array, arange, amin, zeros
- a = arange(4).reshape((2,2))
- assert amin(a) == 0
- # # Minima along the first axis
- # assert (amin(a, axis=0) == array([0, 1])).all()
- # # Minima along the second axis
- # assert (amin(a, axis=1) == array([0, 2])).all()
- # # NaN behaviour
- # b = arange(5, dtype=float)
- # b[2] = NaN
- # assert amin(b) == nan
- # assert nanmin(b) == 0.0
-
- assert amin(range(10)) == 0
- assert amin(array(range(10))) == 0
- assert list(amin(zeros((0, 2)), axis=1)) == []
-
- a = array([[1, 2], [3, 4]])
- out = array([[0, 0], [0, 0]])
- c = amin(a, axis=1, out=out[0])
- assert (c == [1, 3]).all()
- assert (c == out[0]).all()
- assert (c != out[1]).all()
-
- def test_amax(self):
- # tests taken from numpy/core/fromnumeric.py docstring
- from numpypy import array, arange, amax, zeros
- a = arange(4).reshape((2,2))
- assert amax(a) == 3
- # assert (amax(a, axis=0) == array([2, 3])).all()
- # assert (amax(a, axis=1) == array([1, 3])).all()
- # # NaN behaviour
- # b = arange(5, dtype=float)
- # b[2] = NaN
- # assert amax(b) == nan
- # assert nanmax(b) == 4.0
-
- assert amax(range(10)) == 9
- assert amax(array(range(10))) == 9
- assert list(amax(zeros((0, 2)), axis=1)) == []
-
- a = array([[1, 2], [3, 4]])
- out = array([[0, 0], [0, 0]])
- c = amax(a, axis=1, out=out[0])
- assert (c == [2, 4]).all()
- assert (c == out[0]).all()
- assert (c != out[1]).all()
-
- def test_alen(self):
- # tests taken from numpy/core/fromnumeric.py docstring
- from numpypy import array, zeros, alen
- a = zeros((7,4,5))
- assert a.shape[0] == 7
- assert alen(a) == 7
-
- def test_ndim(self):
- # tests taken from numpy/core/fromnumeric.py docstring
- from numpypy import array, ndim
- assert ndim([[1,2,3],[4,5,6]]) == 2
- assert ndim(array([[1,2,3],[4,5,6]])) == 2
- assert ndim(1) == 0
-
- def test_rank(self):
- # tests taken from numpy/core/fromnumeric.py docstring
- from numpypy import array, rank
- assert rank([[1,2,3],[4,5,6]]) == 2
- assert rank(array([[1,2,3],[4,5,6]])) == 2
- assert rank(1) == 0
-
- def test_var(self):
- from numpypy import array, var
- a = array([[1,2],[3,4]])
- assert var(a) == 1.25
- assert (var(a,0) == array([ 1., 1.])).all()
- assert (var(a,1) == array([ 0.25, 0.25])).all()
-
- def test_std(self):
- from numpypy import array, std
- a = array([[1, 2], [3, 4]])
- assert std(a) == 1.1180339887498949
- assert (std(a, axis=0) == array([ 1., 1.])).all()
- assert (std(a, axis=1) == array([ 0.5, 0.5])).all()
-
- def test_mean(self):
- from numpypy import array, mean, arange
- assert mean(array(range(5))) == 2.0
- assert mean(range(5)) == 2.0
- assert (mean(arange(10).reshape(5, 2), axis=0) == [4, 5]).all()
- assert (mean(arange(10).reshape(5, 2), axis=1) == [0.5, 2.5, 4.5, 6.5, 8.5]).all()
-
- def test_reshape(self):
- from numpypy import arange, array, dtype, reshape
- a = arange(12)
- b = reshape(a, (3, 4))
- assert b.shape == (3, 4)
- a = range(12)
- b = reshape(a, (3, 4))
- assert b.shape == (3, 4)
- a = array(range(105)).reshape(3, 5, 7)
- assert reshape(a, (1, -1)).shape == (1, 105)
- assert reshape(a, (1, 1, -1)).shape == (1, 1, 105)
- assert reshape(a, (-1, 1, 1)).shape == (105, 1, 1)
-
- def test_transpose(self):
- from numpypy import arange, array, transpose, ones
- x = arange(4).reshape((2,2))
- assert (transpose(x) == array([[0, 2],[1, 3]])).all()
- # Once axes argument is implemented, add more tests
- import sys
- if '__pypy__' in sys.builtin_module_names:
- raises(NotImplementedError, "transpose(x, axes=(1, 0, 2))")
- # x = ones((1, 2, 3))
- # assert transpose(x, (1, 0, 2)).shape == (2, 1, 3)
-
- def test_fromnumeric(self):
- from numpypy import array, swapaxes
- x = array([[1,2,3]])
- assert (swapaxes(x,0,1) == array([[1], [2], [3]])).all()
- x = array([[[0,1],[2,3]],[[4,5],[6,7]]])
- assert (swapaxes(x,0,2) == array([[[0, 4], [2, 6]],
- [[1, 5], [3, 7]]])).all()
diff --git a/pypy/module/test_lib_pypy/numpypy/core/test_numeric.py b/pypy/module/test_lib_pypy/numpypy/core/test_numeric.py
deleted file mode 100644
--- a/pypy/module/test_lib_pypy/numpypy/core/test_numeric.py
+++ /dev/null
@@ -1,250 +0,0 @@
-from pypy.module.test_lib_pypy.numpypy.test_base import BaseNumpyAppTest
-
-
-class AppTestBaseRepr(BaseNumpyAppTest):
- def test_base3(self):
- from numpypy import base_repr
- assert base_repr(3**5, 3) == '100000'
-
- def test_positive(self):
- from numpypy import base_repr
- assert base_repr(12, 10) == '12'
- assert base_repr(12, 10, 4) == '000012'
- assert base_repr(12, 4) == '30'
- assert base_repr(3731624803700888, 36) == '10QR0ROFCEW'
-
- def test_negative(self):
- from numpypy import base_repr
- assert base_repr(-12, 10) == '-12'
- assert base_repr(-12, 10, 4) == '-000012'
- assert base_repr(-12, 4) == '-30'
-
-
-class AppTestRepr(BaseNumpyAppTest):
- def test_repr(self):
- from numpypy import array
- assert repr(array([1, 2, 3, 4])) == 'array([1, 2, 3, 4])'
-
- def test_repr_2(self):
- from numpypy import array, zeros
- int_size = array(5).dtype.itemsize
- a = array(range(5), float)
- assert repr(a) == "array([ 0., 1., 2., 3., 4.])"
- a = array([], float)
- assert repr(a) == "array([], dtype=float64)"
- a = zeros(1001)
- assert repr(a) == "array([ 0., 0., 0., ..., 0., 0., 0.])"
- a = array(range(5), int)
- if a.dtype.itemsize == int_size:
- assert repr(a) == "array([0, 1, 2, 3, 4])"
- else:
- assert repr(a) == "array([0, 1, 2, 3, 4], dtype=int64)"
- a = array(range(5), 'int32')
- if a.dtype.itemsize == int_size:
- assert repr(a) == "array([0, 1, 2, 3, 4])"
- else:
- assert repr(a) == "array([0, 1, 2, 3, 4], dtype=int32)"
- a = array([], long)
- assert repr(a) == "array([], dtype=int64)"
- a = array([True, False, True, False], "?")
- assert repr(a) == "array([ True, False, True, False], dtype=bool)"
- a = zeros([])
- assert repr(a) == "array(0.0)"
- a = array(0.2)
- assert repr(a) == "array(0.2)"
- a = array([2])
- assert repr(a) == "array([2])"
-
- def test_repr_multi(self):
- from numpypy import arange, zeros, array
- a = zeros((3, 4))
- assert repr(a) == '''array([[ 0., 0., 0., 0.],
- [ 0., 0., 0., 0.],
- [ 0., 0., 0., 0.]])'''
- a = zeros((2, 3, 4))
- assert repr(a) == '''array([[[ 0., 0., 0., 0.],
- [ 0., 0., 0., 0.],
- [ 0., 0., 0., 0.]],
-
- [[ 0., 0., 0., 0.],
- [ 0., 0., 0., 0.],
- [ 0., 0., 0., 0.]]])'''
- a = arange(1002).reshape((2, 501))
- assert repr(a) == '''array([[ 0, 1, 2, ..., 498, 499, 500],
- [ 501, 502, 503, ..., 999, 1000, 1001]])'''
- assert repr(a.T) == '''array([[ 0, 501],
- [ 1, 502],
- [ 2, 503],
- ...,
- [ 498, 999],
- [ 499, 1000],
- [ 500, 1001]])'''
- a = arange(2).reshape((2,1))
- assert repr(a) == '''array([[0],
- [1]])'''
-
- def test_repr_slice(self):
- from numpypy import array, zeros
- a = array(range(5), float)
- b = a[1::2]
- assert repr(b) == "array([ 1., 3.])"
- a = zeros(2002)
- b = a[::2]
- assert repr(b) == "array([ 0., 0., 0., ..., 0., 0., 0.])"
- a = array((range(5), range(5, 10)), dtype="int16")
- b = a[1, 2:]
- assert repr(b) == "array([7, 8, 9], dtype=int16)"
- # an empty slice prints its shape
- b = a[2:1, ]
- assert repr(b) == "array([], shape=(0, 5), dtype=int16)"
-
- def test_str(self):
- from numpypy import array, zeros
- a = array(range(5), float)
- assert str(a) == "[ 0. 1. 2. 3. 4.]"
- assert str((2 * a)[:]) == "[ 0. 2. 4. 6. 8.]"
- a = zeros(1001)
- assert str(a) == "[ 0. 0. 0. ..., 0. 0. 0.]"
-
- a = array(range(5), dtype=long)
- assert str(a) == "[0 1 2 3 4]"
- a = array([True, False, True, False], dtype="?")
- assert str(a) == "[ True False True False]"
-
- a = array(range(5), dtype="int8")
- assert str(a) == "[0 1 2 3 4]"
-
- a = array(range(5), dtype="int16")
- assert str(a) == "[0 1 2 3 4]"
-
- a = array((range(5), range(5, 10)), dtype="int16")
- assert str(a) == "[[0 1 2 3 4]\n [5 6 7 8 9]]"
-
- a = array(3, dtype=int)
- assert str(a) == "3"
-
- a = zeros((400, 400), dtype=int)
- assert str(a) == '[[0 0 0 ..., 0 0 0]\n [0 0 0 ..., 0 0 0]\n [0 0 0 ..., 0 0 0]\n ..., \n [0 0 0 ..., 0 0 0]\n [0 0 0 ..., 0 0 0]\n [0 0 0 ..., 0 0 0]]'
- a = zeros((2, 2, 2))
- r = str(a)
- assert r == '[[[ 0. 0.]\n [ 0. 0.]]\n\n [[ 0. 0.]\n [ 0. 0.]]]'
-
- def test_str_slice(self):
- from numpypy import array, zeros
- a = array(range(5), float)
- b = a[1::2]
- assert str(b) == "[ 1. 3.]"
- a = zeros(2002)
- b = a[::2]
- assert str(b) == "[ 0. 0. 0. ..., 0. 0. 0.]"
- a = array((range(5), range(5, 10)), dtype="int16")
- b = a[1, 2:]
- assert str(b) == "[7 8 9]"
- b = a[2:1, ]
- assert str(b) == "[]"
-
- def test_equal(self):
- from numpypy import array, array_equal
-
- a = [1, 2, 3]
- b = [1, 2, 3]
-
- assert array_equal(a, b)
- assert array_equal(a, array(b))
- assert array_equal(array(a), b)
- assert array_equal(array(a), array(b))
-
- def test_not_equal(self):
- from numpypy import array, array_equal
-
- a = [1, 2, 3]
- b = [1, 2, 4]
-
- assert not array_equal(a, b)
- assert not array_equal(a, array(b))
- assert not array_equal(array(a), b)
- assert not array_equal(array(a), array(b))
-
- def test_mismatched_shape(self):
- from numpypy import array, array_equal
-
- a = [1, 2, 3]
- b = [[1, 2, 3], [1, 2, 3]]
-
- assert not array_equal(a, b)
- assert not array_equal(a, array(b))
- assert not array_equal(array(a), b)
- assert not array_equal(array(a), array(b))
-
- def test_equiv(self):
- import numpypy as np
-
- assert np.array_equiv([1, 2], [1, 2])
- assert not np.array_equiv([1, 2], [1, 3])
- assert np.array_equiv([1, 2], [[1, 2], [1, 2]])
- assert not np.array_equiv([1, 2], [[1, 2, 1, 2], [1, 2, 1, 2]])
- assert not np.array_equiv([1, 2], [[1, 2], [1, 3]])
-
-
-class AppTestNumeric(BaseNumpyAppTest):
- def test_argwhere(self):
- import numpypy as np
- x = np.arange(6).reshape(2,3)
- a = np.argwhere(x>1)
- assert np.array_equal(a,
- [[0, 2],
- [1, 0],
- [1, 1],
- [1, 2]]
- )
-
- def test_flatnonzero(self):
- import numpypy as np
- x = np.arange(-2, 3)
- a = np.flatnonzero(x)
- assert np.array_equal(a, [0, 1, 3, 4])
-
- def test_outer(self):
- from numpypy import array, outer
- a = [1, 2, 3]
- b = [4, 5, 6]
- res = outer(a, b)
- expected = array([[ 4, 5, 6],
- [ 8, 10, 12],
- [12, 15, 18]])
- assert (res == expected).all()
-
- def test_vdot(self):
- import numpypy as np
- a = np.array([1+2j,3+4j])
- b = np.array([5+6j,7+8j])
- c = np.vdot(a, b)
- assert c == (70-8j)
- c = np.vdot(b, a)
- assert c == (70+8j)
-
- a = np.array([[1, 4], [5, 6]])
- b = np.array([[4, 1], [2, 2]])
- c = np.vdot(a, b)
- assert c == 30
- c = np.vdot(b, a)
- assert c == 30
-
- def test_identity(self):
- from numpypy import array, int32, float64, dtype, identity
- a = identity(0)
- assert len(a) == 0
- assert a.dtype == dtype('float64')
- assert a.shape == (0, 0)
- b = identity(1, dtype=int32)
- assert len(b) == 1
- assert b[0][0] == 1
- assert b.shape == (1, 1)
- assert b.dtype == dtype('int32')
- c = identity(2)
- assert c.shape == (2, 2)
- assert (c == [[1, 0], [0, 1]]).all()
- d = identity(3, dtype='int32')
- assert d.shape == (3, 3)
- assert d.dtype == dtype('int32')
- assert (d == [[1, 0, 0], [0, 1, 0], [0, 0, 1]]).all()
diff --git a/pypy/module/test_lib_pypy/numpypy/core/test_shape_base.py b/pypy/module/test_lib_pypy/numpypy/core/test_shape_base.py
deleted file mode 100644
--- a/pypy/module/test_lib_pypy/numpypy/core/test_shape_base.py
+++ /dev/null
@@ -1,131 +0,0 @@
-from pypy.module.test_lib_pypy.numpypy.test_base import BaseNumpyAppTest
-
-
-class AppTestShapeBase(BaseNumpyAppTest):
-
- def test_atleast_1d(self):
- from numpypy import array, array_equal
- import numpypy as np
- a = np.atleast_1d(1.0)
- assert np.array_equal(a, [1.])
-
- x = np.arange(9.0).reshape(3, 3)
- a = np.atleast_1d(x)
- assert np.array_equal(a, [[0., 1., 2.],
- [3., 4., 5.],
- [6., 7., 8.]])
- assert np.atleast_1d(x) is x
-
- a = np.atleast_1d(1, [3, 4])
- assert len(a) == 2
- assert array_equal(a[0], [1])
- assert array_equal(a[1], [3, 4])
-
- def test_atleast_2d(self):
- import numpypy as np
- a = np.atleast_2d(3.0)
- assert np.array_equal(a, [[3.]])
-
- x = np.arange(3.0)
- a = np.atleast_2d(x)
- assert np.array_equal(a, [[0., 1., 2.]])
-
- a = np.atleast_2d(1, [1, 2], [[1, 2]])
- assert len(a) == 3
- assert np.array_equal(a[0], [[1]])
- assert np.array_equal(a[1], [[1, 2]])
- assert np.array_equal(a[2], [[1, 2]])
-
- def test_atleast_3d(self):
- import numpypy as np
-
- a = np.atleast_3d(3.0)
- assert np.array_equal(a, [[[3.]]])
-
- x = np.arange(3.0)
- assert np.atleast_3d(x).shape == (1, 3, 1)
-
- x = np.arange(12.0).reshape(4, 3)
- assert np.atleast_3d(x).shape == (4, 3, 1)
-
- a = np.atleast_3d([1, 2])
- assert np.array_equal(a, [[[1],
- [2]]])
- assert a.shape == (1, 2, 1)
-
- a = np.atleast_3d([[1, 2]])
- assert np.array_equal(a, [[[1],
- [2]]])
- assert a.shape == (1, 2, 1)
-
- a = np.atleast_3d([[[1, 2]]])
- assert np.array_equal(a, [[[1, 2]]])
- assert a.shape == (1, 1, 2)
-
- def test_vstack(self):
- import numpypy as np
-
- a = np.array([1, 2, 3])
- b = np.array([2, 3, 4])
- c = np.vstack((a, b))
- assert np.array_equal(c, [[1, 2, 3],
- [2, 3, 4]])
-
- a = np.array([[1], [2], [3]])
- b = np.array([[2], [3], [4]])
- c = np.vstack((a, b))
- assert np.array_equal(c, [[1],
- [2],
- [3],
- [2],
- [3],
- [4]])
-
- for shape1, shape2 in [[(2, 1), (3, 1)],
- [(2, 4), [3, 4]]]:
- a, b = np.ones(shape1), np.ones(shape2)
- assert np.all(np.vstack((a, b)) ==
- np.ones((a.shape[0] + b.shape[0],
- a.shape[1])))
-
- #skip("https://bugs.pypy.org/issue1394")
- for shape1, shape2 in [[(3, 2, 4), (7, 2, 4)],
- [(0, 2, 7), (10, 2, 7)],
- [(0, 2, 7), (0, 2, 7)]]:
- a, b = np.ones(shape1), np.ones(shape2)
- assert np.all(np.vstack((a, b)) ==
- np.ones((a.shape[0] + b.shape[0],
- a.shape[1],
- a.shape[2])))
-
- def test_hstack(self):
- import numpypy as np
- a = np.array((1, 2, 3))
- b = np.array((2, 3, 4))
- c = np.hstack((a, b))
- assert np.array_equal(c, [1, 2, 3, 2, 3, 4])
-
- a = np.array([[1], [2], [3]])
- b = np.array([[2], [3], [4]])
- c = np.hstack((a, b))
- assert np.array_equal(c, [[1, 2],
- [2, 3],
- [3, 4]])
-
- for shape1, shape2 in [[(1, 2), (1, 3)],
- [(4, 2), (4, 3)]]:
- a, b = np.ones(shape1), np.ones(shape2)
- assert np.all(np.hstack((a, b)) ==
- np.ones((a.shape[0],
- a.shape[1] + b.shape[1])))
-
- #skip("https://bugs.pypy.org/issue1394")
- for shape1, shape2 in [[(2, 3, 4), (2, 7, 4)],
- [(1, 4, 7), (1, 10, 7)],
- [(1, 4, 7), (1, 0, 7)],
- [(1, 0, 7), (1, 0, 7)]]:
- a, b = np.ones(shape1), np.ones(shape2)
- assert np.all(np.hstack((a, b)) ==
- np.ones((a.shape[0],
- a.shape[1] + b.shape[1],
- a.shape[2])))
diff --git a/pypy/module/test_lib_pypy/numpypy/lib/test_function_base.py b/pypy/module/test_lib_pypy/numpypy/lib/test_function_base.py
deleted file mode 100644
--- a/pypy/module/test_lib_pypy/numpypy/lib/test_function_base.py
+++ /dev/null
@@ -1,7 +0,0 @@
-from pypy.module.test_lib_pypy.numpypy.test_base import BaseNumpyAppTest
-
-class AppTestFunctionBase(BaseNumpyAppTest):
- def test_average(self):
- from numpypy import array, average
- assert average(range(10)) == 4.5
- assert average(array(range(10))) == 4.5
diff --git a/pypy/module/test_lib_pypy/numpypy/lib/test_shape_base_lib.py b/pypy/module/test_lib_pypy/numpypy/lib/test_shape_base_lib.py
deleted file mode 100644
--- a/pypy/module/test_lib_pypy/numpypy/lib/test_shape_base_lib.py
+++ /dev/null
@@ -1,34 +0,0 @@
-from pypy.module.test_lib_pypy.numpypy.test_base import BaseNumpyAppTest
-
-class AppTestShapeBase(BaseNumpyAppTest):
- def test_dstack(self):
- import numpypy as np
- a = np.array((1, 2, 3))
- b = np.array((2, 3, 4))
- c = np.dstack((a, b))
- assert np.array_equal(c, [[[1, 2], [2, 3], [3, 4]]])
-
- a = np.array([[1], [2], [3]])
- b = np.array([[2], [3], [4]])
- c = np.dstack((a, b))
- assert np.array_equal(c, [[[1, 2]], [[2, 3]], [[3, 4]]])
-
- #skip("https://bugs.pypy.org/issue1394")
- for shape1, shape2 in [[(4, 2, 3), (4, 2, 7)],
- [(7, 2, 0), (7, 2, 10)],
- [(7, 2, 0), (7, 2, 0)]]:
- a, b = np.ones(shape1), np.ones(shape2)
- assert np.all(np.dstack((a, b)) ==
- np.ones((a.shape[0],
- a.shape[1],
- a.shape[2] + b.shape[2])))
-
- for shape1, shape2 in [[(4, 2, 3, 5), (4, 2, 7, 5)],
- [(7, 2, 0, 5), (7, 2, 10, 5)],
- [(7, 2, 0, 5), (7, 2, 0, 5)]]:
- a, b = np.ones(shape1), np.ones(shape2)
- assert np.all(np.dstack((a, b)) ==
- np.ones((a.shape[0],
- a.shape[1],
- a.shape[2] + b.shape[2],
- a.shape[3])))
diff --git a/pypy/module/test_lib_pypy/numpypy/lib/test_twodim_base.py b/pypy/module/test_lib_pypy/numpypy/lib/test_twodim_base.py
deleted file mode 100644
--- a/pypy/module/test_lib_pypy/numpypy/lib/test_twodim_base.py
+++ /dev/null
@@ -1,30 +0,0 @@
-from pypy.module.test_lib_pypy.numpypy.test_base import BaseNumpyAppTest
-
-class AppTestTwoDimBase(BaseNumpyAppTest):
- def test_eye(self):
- from numpypy import eye, int32, dtype
- a = eye(0)
- assert len(a) == 0
- assert a.dtype == dtype('float64')
- assert a.shape == (0, 0)
- b = eye(1, dtype=int32)
- assert len(b) == 1
- assert b[0][0] == 1
- assert b.shape == (1, 1)
- assert b.dtype == dtype('int32')
- c = eye(2)
- assert c.shape == (2, 2)
- assert (c == [[1, 0], [0, 1]]).all()
- d = eye(3, dtype='int32')
- assert d.shape == (3, 3)
- assert d.dtype == dtype('int32')
- assert (d == [[1, 0, 0], [0, 1, 0], [0, 0, 1]]).all()
- e = eye(3, 4)
- assert e.shape == (3, 4)
- assert (e == [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0]]).all()
- f = eye(2, 4, k=3)
- assert f.shape == (2, 4)
- assert (f == [[0, 0, 0, 1], [0, 0, 0, 0]]).all()
- g = eye(3, 4, k=-1)
- assert g.shape == (3, 4)
- assert (g == [[0, 0, 0, 0], [1, 0, 0, 0], [0, 1, 0, 0]]).all()
diff --git a/pypy/module/test_lib_pypy/numpypy/test_base.py b/pypy/module/test_lib_pypy/numpypy/test_base.py
deleted file mode 100644
--- a/pypy/module/test_lib_pypy/numpypy/test_base.py
+++ /dev/null
@@ -1,12 +0,0 @@
-class BaseNumpyAppTest(object):
- @classmethod
- def setup_class(cls):
- if cls.runappdirect:
- try:
- import numpy
- except ImportError:
- skip("no numpy found")
- import sys
- sys.modules['numpypy'] = numpy
- else:
- skip("app-level tests")
diff --git a/pypy/module/test_lib_pypy/numpypy/test_numpy.py b/pypy/module/test_lib_pypy/numpypy/test_numpy.py
deleted file mode 100644
--- a/pypy/module/test_lib_pypy/numpypy/test_numpy.py
+++ /dev/null
@@ -1,67 +0,0 @@
-from pypy.conftest import option
-import py, sys
-from pypy.module.test_lib_pypy.numpypy.test_base import BaseNumpyAppTest
-
-class AppTestNumpy(BaseNumpyAppTest):
- def test_min_max_after_import(self):
- import __builtin__
- from __builtin__ import *
-
- from numpypy import *
- assert min is __builtin__.min
- assert max is __builtin__.max
-
- assert min(1, 100) == 1
- assert min(100, 1) == 1
-
- assert max(1, 100) == 100
- assert max(100, 1) == 100
-
- assert min(4, 3, 2, 1) == 1
- assert max(1, 2, 3, 4) == 4
-
- from numpypy import min, max, amin, amax
- assert min is not __builtin__.min
- assert max is not __builtin__.max
- assert min is amin
- assert max is amax
-
- def test_builtin_aliases(self):
- import __builtin__
- import numpypy
- from numpypy import *
-
- for name in ['bool', 'int', 'long', 'float', 'complex', 'object',
- 'unicode', 'str']:
- assert name not in locals()
- assert getattr(numpypy, name) is getattr(__builtin__, name)
-
- def test_typeinfo(self):
- import numpypy
- assert 'typeinfo' not in dir(numpypy)
- assert 'typeinfo' in dir(numpypy.core.multiarray)
-
- def test_set_string_function(self):
- import numpypy
- assert numpypy.set_string_function is not \
- numpypy.core.multiarray.set_string_function
-
- def test_constants(self):
- import math
- import numpypy
- assert numpypy.PZERO == numpypy.NZERO == 0.0
- assert math.isinf(numpypy.inf)
- assert math.isnan(numpypy.nan)
-
- def test___all__(self):
- import numpypy
- assert '__all__' in dir(numpypy)
- assert 'numpypy' not in dir(numpypy)
-
- def test_get_include(self):
- import numpypy, os, sys
- assert 'get_include' in dir(numpypy)
- path = numpypy.get_include()
- if not hasattr(sys, 'pypy_translation_info'):
- skip("pypy white-box test")
- assert os.path.exists(path + '/numpy/arrayobject.h')
More information about the pypy-commit
mailing list