Author: Alex Gaynor <[email protected]> Branch: numpy-exp Changeset: r44172:1c93d5fbd79e Date: 2011-05-14 17:44 -0500 http://bitbucket.org/pypy/pypy/changeset/1c93d5fbd79e/
Log: Renamed this file to represent what it actually tests. diff --git a/pypy/module/micronumpy/test/test_numarray.py b/pypy/module/micronumpy/test/test_numarray.py new file mode 100644 --- /dev/null +++ b/pypy/module/micronumpy/test/test_numarray.py @@ -0,0 +1,141 @@ +import py + +from pypy.module.micronumpy.test.test_base import BaseNumpyAppTest + + +class AppTestNumArray(BaseNumpyAppTest): + def test_type(self): + from numpy import array + ar = array(range(5)) + assert type(ar) is type(ar + ar) + + def test_init(self): + from numpy import zeros + a = zeros(15) + # Check that storage was actually zero'd. + assert a[10] == 0.0 + # And check that changes stick. + a[13] = 5.3 + assert a[13] == 5.3 + + def test_iterator_init(self): + from numpy import array + a = array(range(5)) + assert a[3] == 3 + + def test_getitem(self): + from numpy import array + a = array(range(5)) + raises(IndexError, "a[5]") + a = a + a + raises(IndexError, "a[5]") + assert a[-1] == 8 + raises(IndexError, "a[-6]") + + def test_setitem(self): + from numpy import array + a = array(range(5)) + a[-1] = 5.0 + assert a[4] == 5.0 + raises(IndexError, "a[5] = 0.0") + raises(IndexError, "a[-6] = 3.0") + + def test_len(self): + from numpy import array + a = array(range(5)) + assert len(a) == 5 + assert len(a + a) == 5 + + def test_add(self): + from numpy import array + a = array(range(5)) + b = a + a + for i in range(5): + assert b[i] == i + i + + def test_add_other(self): + from numpy import array + a = array(range(5)) + b = array(reversed(range(5))) + c = a + b + for i in range(5): + assert c[i] == 4 + + def test_add_constant(self): + from numpy import array + a = array(range(5)) + b = a + 5 + for i in range(5): + assert b[i] == i + 5 + + def test_subtract(self): + from numpy import array + a = array(range(5)) + b = a - a + for i in range(5): + assert b[i] == 0 + + def test_subtract_other(self): + from numpy import array + a = array(range(5)) + b = array([1, 1, 1, 1, 1]) + c = a - b + for i in range(5): + assert c[i] == i - 1 + + def test_subtract_constant(self): + from numpy import array + a = array(range(5)) + b = a - 5 + for i in range(5): + assert b[i] == i - 5 + + def test_mul(self): + from numpy import array + a = array(range(5)) + b = a * a + for i in range(5): + assert b[i] == i * i + + def test_mul_constant(self): + from numpy import array + a = array(range(5)) + b = a * 5 + for i in range(5): + assert b[i] == i * 5 + + def test_div(self): + from numpy import array + a = array(range(1, 6)) + b = a / a + for i in range(5): + assert b[i] == 1 + + def test_div_other(self): + from numpy import array + a = array(range(5)) + b = array([2, 2, 2, 2, 2]) + c = a / b + for i in range(5): + assert c[i] == i / 2.0 + + def test_div_constant(self): + from numpy import array + a = array(range(5)) + b = a / 5.0 + for i in range(5): + assert b[i] == i / 5.0 + + def test_auto_force(self): + from numpy import array + a = array(range(5)) + b = a - 1 + a[2] = 3 + for i in range(5): + assert b[i] == i - 1 + + a = array(range(5)) + b = a + a + c = b + b + b[1] = 5 + assert c[1] == 4 \ No newline at end of file diff --git a/pypy/module/micronumpy/test/test_numpy.py b/pypy/module/micronumpy/test/test_numpy.py deleted file mode 100644 --- a/pypy/module/micronumpy/test/test_numpy.py +++ /dev/null @@ -1,136 +0,0 @@ -import py - -from pypy.module.micronumpy.test.test_base import BaseNumpyAppTest - - -class AppTestNumArray(BaseNumpyAppTest): - def test_init(self): - from numpy import zeros - a = zeros(15) - # Check that storage was actually zero'd. - assert a[10] == 0.0 - # And check that changes stick. - a[13] = 5.3 - assert a[13] == 5.3 - - def test_iterator_init(self): - from numpy import array - a = array(range(5)) - assert a[3] == 3 - - def test_getitem(self): - from numpy import array - a = array(range(5)) - raises(IndexError, "a[5]") - a = a + a - raises(IndexError, "a[5]") - assert a[-1] == 8 - raises(IndexError, "a[-6]") - - def test_setitem(self): - from numpy import array - a = array(range(5)) - a[-1] = 5.0 - assert a[4] == 5.0 - raises(IndexError, "a[5] = 0.0") - raises(IndexError, "a[-6] = 3.0") - - def test_len(self): - from numpy import array - a = array(range(5)) - assert len(a) == 5 - assert len(a + a) == 5 - - def test_add(self): - from numpy import array - a = array(range(5)) - b = a + a - for i in range(5): - assert b[i] == i + i - - def test_add_other(self): - from numpy import array - a = array(range(5)) - b = array(reversed(range(5))) - c = a + b - for i in range(5): - assert c[i] == 4 - - def test_add_constant(self): - from numpy import array - a = array(range(5)) - b = a + 5 - for i in range(5): - assert b[i] == i + 5 - - def test_subtract(self): - from numpy import array - a = array(range(5)) - b = a - a - for i in range(5): - assert b[i] == 0 - - def test_subtract_other(self): - from numpy import array - a = array(range(5)) - b = array([1, 1, 1, 1, 1]) - c = a - b - for i in range(5): - assert c[i] == i - 1 - - def test_subtract_constant(self): - from numpy import array - a = array(range(5)) - b = a - 5 - for i in range(5): - assert b[i] == i - 5 - - def test_mul(self): - from numpy import array - a = array(range(5)) - b = a * a - for i in range(5): - assert b[i] == i * i - - def test_mul_constant(self): - from numpy import array - a = array(range(5)) - b = a * 5 - for i in range(5): - assert b[i] == i * 5 - - def test_div(self): - from numpy import array - a = array(range(1, 6)) - b = a / a - for i in range(5): - assert b[i] == 1 - - def test_div_other(self): - from numpy import array - a = array(range(5)) - b = array([2, 2, 2, 2, 2]) - c = a / b - for i in range(5): - assert c[i] == i / 2.0 - - def test_div_constant(self): - from numpy import array - a = array(range(5)) - b = a / 5.0 - for i in range(5): - assert b[i] == i / 5.0 - - def test_auto_force(self): - from numpy import array - a = array(range(5)) - b = a - 1 - a[2] = 3 - for i in range(5): - assert b[i] == i - 1 - - a = array(range(5)) - b = a + a - c = b + b - b[1] = 5 - assert c[1] == 4 \ No newline at end of file _______________________________________________ pypy-commit mailing list [email protected] http://mail.python.org/mailman/listinfo/pypy-commit
