[pypy-commit] pypy default: merge import-numpy, rename numpypy to _numpypy
fijal
noreply at buildbot.pypy.org
Sat Jan 7 21:01:47 CET 2012
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch:
Changeset: r51122:cc8f110fc52d
Date: 2012-01-07 22:00 +0200
http://bitbucket.org/pypy/pypy/changeset/cc8f110fc52d/
Log: merge import-numpy, rename numpypy to _numpypy
diff --git a/pypy/module/micronumpy/__init__.py b/pypy/module/micronumpy/__init__.py
--- a/pypy/module/micronumpy/__init__.py
+++ b/pypy/module/micronumpy/__init__.py
@@ -9,7 +9,7 @@
appleveldefs = {}
class Module(MixedModule):
- applevel_name = 'numpypy'
+ applevel_name = '_numpypy'
submodules = {
'pypy': PyPyModule
diff --git a/pypy/module/micronumpy/app_numpy.py b/pypy/module/micronumpy/app_numpy.py
--- a/pypy/module/micronumpy/app_numpy.py
+++ b/pypy/module/micronumpy/app_numpy.py
@@ -1,6 +1,6 @@
import math
-import numpypy
+import _numpypy
inf = float("inf")
@@ -14,29 +14,29 @@
return mean(a)
def identity(n, dtype=None):
- a = numpypy.zeros((n,n), dtype=dtype)
+ a = _numpypy.zeros((n,n), dtype=dtype)
for i in range(n):
a[i][i] = 1
return a
def mean(a):
if not hasattr(a, "mean"):
- a = numpypy.array(a)
+ a = _numpypy.array(a)
return a.mean()
def sum(a):
if not hasattr(a, "sum"):
- a = numpypy.array(a)
+ a = _numpypy.array(a)
return a.sum()
def min(a):
if not hasattr(a, "min"):
- a = numpypy.array(a)
+ a = _numpypy.array(a)
return a.min()
def max(a):
if not hasattr(a, "max"):
- a = numpypy.array(a)
+ a = _numpypy.array(a)
return a.max()
def arange(start, stop=None, step=1, dtype=None):
@@ -47,9 +47,9 @@
stop = start
start = 0
if dtype is None:
- test = numpypy.array([start, stop, step, 0])
+ test = _numpypy.array([start, stop, step, 0])
dtype = test.dtype
- arr = numpypy.zeros(int(math.ceil((stop - start) / step)), dtype=dtype)
+ arr = _numpypy.zeros(int(math.ceil((stop - start) / step)), dtype=dtype)
i = start
for j in range(arr.size):
arr[j] = i
@@ -90,5 +90,5 @@
you should assign the new shape to the shape attribute of the array
'''
if not hasattr(a, 'reshape'):
- a = numpypy.array(a)
+ a = _numpypy.array(a)
return a.reshape(shape)
diff --git a/pypy/module/micronumpy/test/test_dtypes.py b/pypy/module/micronumpy/test/test_dtypes.py
--- a/pypy/module/micronumpy/test/test_dtypes.py
+++ b/pypy/module/micronumpy/test/test_dtypes.py
@@ -3,7 +3,7 @@
class AppTestDtypes(BaseNumpyAppTest):
def test_dtype(self):
- from numpypy import dtype
+ from _numpypy import dtype
d = dtype('?')
assert d.num == 0
@@ -14,7 +14,7 @@
raises(TypeError, dtype, 1042)
def test_dtype_with_types(self):
- from numpypy import dtype
+ from _numpypy import dtype
assert dtype(bool).num == 0
assert dtype(int).num == 7
@@ -22,13 +22,13 @@
assert dtype(float).num == 12
def test_array_dtype_attr(self):
- from numpypy import array, dtype
+ from _numpypy import array, dtype
a = array(range(5), long)
assert a.dtype is dtype(long)
def test_repr_str(self):
- from numpypy import dtype
+ from _numpypy import dtype
assert repr(dtype) == "<type 'numpypy.dtype'>"
d = dtype('?')
@@ -36,7 +36,7 @@
assert str(d) == "bool"
def test_bool_array(self):
- from numpypy import array, False_, True_
+ from _numpypy import array, False_, True_
a = array([0, 1, 2, 2.5], dtype='?')
assert a[0] is False_
@@ -44,7 +44,7 @@
assert a[i] is True_
def test_copy_array_with_dtype(self):
- from numpypy import array, False_, True_, int64
+ from _numpypy import array, False_, True_, int64
a = array([0, 1, 2, 3], dtype=long)
# int on 64-bit, long in 32-bit
@@ -58,35 +58,35 @@
assert b[0] is False_
def test_zeros_bool(self):
- from numpypy import zeros, False_
+ from _numpypy import zeros, False_
a = zeros(10, dtype=bool)
for i in range(10):
assert a[i] is False_
def test_ones_bool(self):
- from numpypy import ones, True_
+ from _numpypy import ones, True_
a = ones(10, dtype=bool)
for i in range(10):
assert a[i] is True_
def test_zeros_long(self):
- from numpypy import zeros, int64
+ from _numpypy import zeros, int64
a = zeros(10, dtype=long)
for i in range(10):
assert isinstance(a[i], int64)
assert a[1] == 0
def test_ones_long(self):
- from numpypy import ones, int64
+ from _numpypy import ones, int64
a = ones(10, dtype=long)
for i in range(10):
assert isinstance(a[i], int64)
assert a[1] == 1
def test_overflow(self):
- from numpypy import array, dtype
+ from _numpypy import array, dtype
assert array([128], 'b')[0] == -128
assert array([256], 'B')[0] == 0
assert array([32768], 'h')[0] == -32768
@@ -98,7 +98,7 @@
raises(OverflowError, "array([2**64], 'Q')")
def test_bool_binop_types(self):
- from numpypy import array, dtype
+ from _numpypy import array, dtype
types = [
'?', 'b', 'B', 'h', 'H', 'i', 'I', 'l', 'L', 'q', 'Q', 'f', 'd'
]
@@ -107,7 +107,7 @@
assert (a + array([0], t)).dtype is dtype(t)
def test_binop_types(self):
- from numpypy import array, dtype
+ from _numpypy import array, dtype
tests = [('b','B','h'), ('b','h','h'), ('b','H','i'), ('b','i','i'),
('b','l','l'), ('b','q','q'), ('b','Q','d'), ('B','h','h'),
('B','H','H'), ('B','i','i'), ('B','I','I'), ('B','l','l'),
@@ -129,7 +129,7 @@
assert (array([1], d1) + array([1], d2)).dtype is dtype(dout)
def test_add_int8(self):
- from numpypy import array, dtype
+ from _numpypy import array, dtype
a = array(range(5), dtype="int8")
b = a + a
@@ -138,7 +138,7 @@
assert b[i] == i * 2
def test_add_int16(self):
- from numpypy import array, dtype
+ from _numpypy import array, dtype
a = array(range(5), dtype="int16")
b = a + a
@@ -147,7 +147,7 @@
assert b[i] == i * 2
def test_add_uint32(self):
- from numpypy import array, dtype
+ from _numpypy import array, dtype
a = array(range(5), dtype="I")
b = a + a
@@ -156,19 +156,19 @@
assert b[i] == i * 2
def test_shape(self):
- from numpypy import dtype
+ from _numpypy import dtype
assert dtype(long).shape == ()
def test_cant_subclass(self):
- from numpypy import dtype
+ from _numpypy import dtype
# You can't subclass dtype
raises(TypeError, type, "Foo", (dtype,), {})
class AppTestTypes(BaseNumpyAppTest):
def test_abstract_types(self):
- import numpypy as numpy
+ import _numpypy as numpy
raises(TypeError, numpy.generic, 0)
raises(TypeError, numpy.number, 0)
raises(TypeError, numpy.integer, 0)
@@ -181,7 +181,7 @@
raises(TypeError, numpy.inexact, 0)
def test_bool(self):
- import numpypy as numpy
+ import _numpypy as numpy
assert numpy.bool_.mro() == [numpy.bool_, numpy.generic, object]
assert numpy.bool_(3) is numpy.True_
@@ -196,7 +196,7 @@
assert numpy.bool_("False") is numpy.True_
def test_int8(self):
- import numpypy as numpy
+ import _numpypy as numpy
assert numpy.int8.mro() == [numpy.int8, numpy.signedinteger, numpy.integer, numpy.number, numpy.generic, object]
@@ -218,7 +218,7 @@
assert numpy.int8('128') == -128
def test_uint8(self):
- import numpypy as numpy
+ import _numpypy as numpy
assert numpy.uint8.mro() == [numpy.uint8, numpy.unsignedinteger, numpy.integer, numpy.number, numpy.generic, object]
@@ -241,7 +241,7 @@
assert numpy.uint8('256') == 0
def test_int16(self):
- import numpypy as numpy
+ import _numpypy as numpy
x = numpy.int16(3)
assert x == 3
@@ -251,7 +251,7 @@
assert numpy.int16('32768') == -32768
def test_uint16(self):
- import numpypy as numpy
+ import _numpypy as numpy
assert numpy.uint16(65535) == 65535
assert numpy.uint16(65536) == 0
@@ -260,7 +260,7 @@
def test_int32(self):
import sys
- import numpypy as numpy
+ import _numpypy as numpy
x = numpy.int32(23)
assert x == 23
@@ -275,7 +275,7 @@
def test_uint32(self):
import sys
- import numpypy as numpy
+ import _numpypy as numpy
assert numpy.uint32(10) == 10
@@ -286,14 +286,14 @@
assert numpy.uint32('4294967296') == 0
def test_int_(self):
- import numpypy as numpy
+ import _numpypy as numpy
assert numpy.int_ is numpy.dtype(int).type
assert numpy.int_.mro() == [numpy.int_, numpy.signedinteger, numpy.integer, numpy.number, numpy.generic, int, object]
def test_int64(self):
import sys
- import numpypy as numpy
+ import _numpypy as numpy
if sys.maxint == 2 ** 63 -1:
assert numpy.int64.mro() == [numpy.int64, numpy.signedinteger, numpy.integer, numpy.number, numpy.generic, int, object]
@@ -315,7 +315,7 @@
def test_uint64(self):
import sys
- import numpypy as numpy
+ import _numpypy as numpy
assert numpy.uint64.mro() == [numpy.uint64, numpy.unsignedinteger, numpy.integer, numpy.number, numpy.generic, object]
@@ -330,7 +330,7 @@
raises(OverflowError, numpy.uint64(18446744073709551616))
def test_float32(self):
- import numpypy as numpy
+ import _numpypy as numpy
assert numpy.float32.mro() == [numpy.float32, numpy.floating, numpy.inexact, numpy.number, numpy.generic, object]
@@ -339,7 +339,7 @@
raises(ValueError, numpy.float32, '23.2df')
def test_float64(self):
- import numpypy as numpy
+ import _numpypy as numpy
assert numpy.float64.mro() == [numpy.float64, numpy.floating, numpy.inexact, numpy.number, numpy.generic, float, object]
@@ -352,7 +352,7 @@
raises(ValueError, numpy.float64, '23.2df')
def test_subclass_type(self):
- import numpypy as numpy
+ import _numpypy as numpy
class X(numpy.float64):
def m(self):
diff --git a/pypy/module/micronumpy/test/test_module.py b/pypy/module/micronumpy/test/test_module.py
--- a/pypy/module/micronumpy/test/test_module.py
+++ b/pypy/module/micronumpy/test/test_module.py
@@ -3,33 +3,33 @@
class AppTestNumPyModule(BaseNumpyAppTest):
def test_mean(self):
- from numpypy import array, mean
+ from _numpypy import array, mean
assert mean(array(range(5))) == 2.0
assert mean(range(5)) == 2.0
def test_average(self):
- from numpypy import array, average
+ from _numpypy import array, average
assert average(range(10)) == 4.5
assert average(array(range(10))) == 4.5
def test_sum(self):
- from numpypy import array, sum
+ from _numpypy import array, sum
assert sum(range(10)) == 45
assert sum(array(range(10))) == 45
def test_min(self):
- from numpypy import array, min
+ from _numpypy import array, min
assert min(range(10)) == 0
assert min(array(range(10))) == 0
def test_max(self):
- from numpypy import array, max
+ from _numpypy import array, max
assert max(range(10)) == 9
assert max(array(range(10))) == 9
def test_constants(self):
import math
- from numpypy import inf, e, pi
+ from _numpypy import inf, e, pi
assert type(inf) is float
assert inf == float("inf")
assert e == math.e
diff --git a/pypy/module/micronumpy/test/test_numarray.py b/pypy/module/micronumpy/test/test_numarray.py
--- a/pypy/module/micronumpy/test/test_numarray.py
+++ b/pypy/module/micronumpy/test/test_numarray.py
@@ -161,7 +161,7 @@
class AppTestNumArray(BaseNumpyAppTest):
def test_ndarray(self):
- from numpypy import ndarray, array, dtype
+ from _numpypy import ndarray, array, dtype
assert type(ndarray) is type
assert type(array) is not type
@@ -176,12 +176,12 @@
assert a.dtype is dtype(int)
def test_type(self):
- from numpypy import array
+ from _numpypy import array
ar = array(range(5))
assert type(ar) is type(ar + ar)
def test_ndim(self):
- from numpypy import array
+ from _numpypy import array
x = array(0.2)
assert x.ndim == 0
x = array([1, 2])
@@ -190,12 +190,12 @@
assert x.ndim == 2
x = array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]])
assert x.ndim == 3
- # numpy actually raises an AttributeError, but numpypy raises an
+ # numpy actually raises an AttributeError, but _numpypy raises an
# TypeError
raises(TypeError, 'x.ndim = 3')
def test_init(self):
- from numpypy import zeros
+ from _numpypy import zeros
a = zeros(15)
# Check that storage was actually zero'd.
assert a[10] == 0.0
@@ -204,7 +204,7 @@
assert a[13] == 5.3
def test_size(self):
- from numpypy import array
+ from _numpypy import array
assert array(3).size == 1
a = array([1, 2, 3])
assert a.size == 3
@@ -215,13 +215,13 @@
Test that empty() works.
"""
- from numpypy import empty
+ from _numpypy import empty
a = empty(2)
a[1] = 1.0
assert a[1] == 1.0
def test_ones(self):
- from numpypy import ones
+ from _numpypy import ones
a = ones(3)
assert len(a) == 3
assert a[0] == 1
@@ -230,7 +230,7 @@
assert a[2] == 4
def test_copy(self):
- from numpypy import arange, array
+ from _numpypy import arange, array
a = arange(5)
b = a.copy()
for i in xrange(5):
@@ -247,12 +247,12 @@
assert (c == b).all()
def test_iterator_init(self):
- from numpypy import array
+ from _numpypy import array
a = array(range(5))
assert a[3] == 3
def test_getitem(self):
- from numpypy import array
+ from _numpypy import array
a = array(range(5))
raises(IndexError, "a[5]")
a = a + a
@@ -261,7 +261,7 @@
raises(IndexError, "a[-6]")
def test_getitem_tuple(self):
- from numpypy import array
+ from _numpypy import array
a = array(range(5))
raises(IndexError, "a[(1,2)]")
for i in xrange(5):
@@ -271,7 +271,7 @@
assert a[i] == b[i]
def test_setitem(self):
- from numpypy import array
+ from _numpypy import array
a = array(range(5))
a[-1] = 5.0
assert a[4] == 5.0
@@ -279,7 +279,7 @@
raises(IndexError, "a[-6] = 3.0")
def test_setitem_tuple(self):
- from numpypy import array
+ from _numpypy import array
a = array(range(5))
raises(IndexError, "a[(1,2)] = [0,1]")
for i in xrange(5):
@@ -290,7 +290,7 @@
assert a[i] == i
def test_setslice_array(self):
- from numpypy import array
+ from _numpypy import array
a = array(range(5))
b = array(range(2))
a[1:4:2] = b
@@ -301,7 +301,7 @@
assert b[1] == 0.
def test_setslice_of_slice_array(self):
- from numpypy import array, zeros
+ from _numpypy import array, zeros
a = zeros(5)
a[::2] = array([9., 10., 11.])
assert a[0] == 9.
@@ -320,7 +320,7 @@
assert a[0] == 3.
def test_setslice_list(self):
- from numpypy import array
+ from _numpypy import array
a = array(range(5), float)
b = [0., 1.]
a[1:4:2] = b
@@ -328,14 +328,14 @@
assert a[3] == 1.
def test_setslice_constant(self):
- from numpypy import array
+ from _numpypy import array
a = array(range(5), float)
a[1:4:2] = 0.
assert a[1] == 0.
assert a[3] == 0.
def test_scalar(self):
- from numpypy import array, dtype
+ from _numpypy import array, dtype
a = array(3)
raises(IndexError, "a[0]")
raises(IndexError, "a[0] = 5")
@@ -344,13 +344,13 @@
assert a.dtype is dtype(int)
def test_len(self):
- from numpypy import array
+ from _numpypy import array
a = array(range(5))
assert len(a) == 5
assert len(a + a) == 5
def test_shape(self):
- from numpypy import array
+ from _numpypy import array
a = array(range(5))
assert a.shape == (5,)
b = a + a
@@ -359,7 +359,7 @@
assert c.shape == (3,)
def test_set_shape(self):
- from numpypy import array, zeros
+ from _numpypy import array, zeros
a = array([])
a.shape = []
a = array(range(12))
@@ -379,7 +379,7 @@
a.shape = (1,)
def test_reshape(self):
- from numpypy import array, zeros
+ from _numpypy import array, zeros
a = array(range(12))
exc = raises(ValueError, "b = a.reshape((3, 10))")
assert str(exc.value) == "total size of new array must be unchanged"
@@ -392,7 +392,7 @@
a.shape = (12, 2)
def test_slice_reshape(self):
- from numpypy import zeros, arange
+ from _numpypy import zeros, arange
a = zeros((4, 2, 3))
b = a[::2, :, :]
b.shape = (2, 6)
@@ -428,13 +428,13 @@
raises(ValueError, arange(10).reshape, (5, -1, -1))
def test_reshape_varargs(self):
- from numpypy import arange
+ from _numpypy import arange
z = arange(96).reshape(12, -1)
y = z.reshape(4, 3, 8)
assert y.shape == (4, 3, 8)
def test_add(self):
- from numpypy import array
+ from _numpypy import array
a = array(range(5))
b = a + a
for i in range(5):
@@ -447,7 +447,7 @@
assert c[i] == bool(a[i] + b[i])
def test_add_other(self):
- from numpypy import array
+ from _numpypy import array
a = array(range(5))
b = array([i for i in reversed(range(5))])
c = a + b
@@ -455,20 +455,20 @@
assert c[i] == 4
def test_add_constant(self):
- from numpypy import array
+ from _numpypy import array
a = array(range(5))
b = a + 5
for i in range(5):
assert b[i] == i + 5
def test_radd(self):
- from numpypy import array
+ from _numpypy import array
r = 3 + array(range(3))
for i in range(3):
assert r[i] == i + 3
def test_add_list(self):
- from numpypy import array, ndarray
+ from _numpypy import array, ndarray
a = array(range(5))
b = list(reversed(range(5)))
c = a + b
@@ -477,14 +477,14 @@
assert c[i] == 4
def test_subtract(self):
- from numpypy import array
+ from _numpypy import array
a = array(range(5))
b = a - a
for i in range(5):
assert b[i] == 0
def test_subtract_other(self):
- from numpypy import array
+ from _numpypy import array
a = array(range(5))
b = array([1, 1, 1, 1, 1])
c = a - b
@@ -492,34 +492,34 @@
assert c[i] == i - 1
def test_subtract_constant(self):
- from numpypy import array
+ from _numpypy import array
a = array(range(5))
b = a - 5
for i in range(5):
assert b[i] == i - 5
def test_scalar_subtract(self):
- from numpypy import int32
+ from _numpypy import int32
assert int32(2) - 1 == 1
assert 1 - int32(2) == -1
def test_mul(self):
- import numpypy
+ import _numpypy
- a = numpypy.array(range(5))
+ a = _numpypy.array(range(5))
b = a * a
for i in range(5):
assert b[i] == i * i
- a = numpypy.array(range(5), dtype=bool)
+ a = _numpypy.array(range(5), dtype=bool)
b = a * a
- assert b.dtype is numpypy.dtype(bool)
- assert b[0] is numpypy.False_
+ assert b.dtype is _numpypy.dtype(bool)
+ assert b[0] is _numpypy.False_
for i in range(1, 5):
- assert b[i] is numpypy.True_
+ assert b[i] is _numpypy.True_
def test_mul_constant(self):
- from numpypy import array
+ from _numpypy import array
a = array(range(5))
b = a * 5
for i in range(5):
@@ -527,7 +527,7 @@
def test_div(self):
from math import isnan
- from numpypy import array, dtype, inf
+ from _numpypy import array, dtype, inf
a = array(range(1, 6))
b = a / a
@@ -559,7 +559,7 @@
assert c[2] == -inf
def test_div_other(self):
- from numpypy import array
+ from _numpypy import array
a = array(range(5))
b = array([2, 2, 2, 2, 2], float)
c = a / b
@@ -567,14 +567,14 @@
assert c[i] == i / 2.0
def test_div_constant(self):
- from numpypy import array
+ from _numpypy import array
a = array(range(5))
b = a / 5.0
for i in range(5):
assert b[i] == i / 5.0
def test_pow(self):
- from numpypy import array
+ from _numpypy import array
a = array(range(5), float)
b = a ** a
for i in range(5):
@@ -584,7 +584,7 @@
assert (a ** 2 == a * a).all()
def test_pow_other(self):
- from numpypy import array
+ from _numpypy import array
a = array(range(5), float)
b = array([2, 2, 2, 2, 2])
c = a ** b
@@ -592,14 +592,14 @@
assert c[i] == i ** 2
def test_pow_constant(self):
- from numpypy import array
+ from _numpypy import array
a = array(range(5), float)
b = a ** 2
for i in range(5):
assert b[i] == i ** 2
def test_mod(self):
- from numpypy import array
+ from _numpypy import array
a = array(range(1, 6))
b = a % a
for i in range(5):
@@ -612,7 +612,7 @@
assert b[i] == 1
def test_mod_other(self):
- from numpypy import array
+ from _numpypy import array
a = array(range(5))
b = array([2, 2, 2, 2, 2])
c = a % b
@@ -620,14 +620,14 @@
assert c[i] == i % 2
def test_mod_constant(self):
- from numpypy import array
+ from _numpypy import array
a = array(range(5))
b = a % 2
for i in range(5):
assert b[i] == i % 2
def test_pos(self):
- from numpypy import array
+ from _numpypy import array
a = array([1., -2., 3., -4., -5.])
b = +a
for i in range(5):
@@ -638,7 +638,7 @@
assert a[i] == i
def test_neg(self):
- from numpypy import array
+ from _numpypy import array
a = array([1., -2., 3., -4., -5.])
b = -a
for i in range(5):
@@ -649,7 +649,7 @@
assert a[i] == -i
def test_abs(self):
- from numpypy import array
+ from _numpypy import array
a = array([1., -2., 3., -4., -5.])
b = abs(a)
for i in range(5):
@@ -660,7 +660,7 @@
assert a[i + 5] == abs(i)
def test_auto_force(self):
- from numpypy import array
+ from _numpypy import array
a = array(range(5))
b = a - 1
a[2] = 3
@@ -674,7 +674,7 @@
assert c[1] == 4
def test_getslice(self):
- from numpypy import array
+ from _numpypy import array
a = array(range(5))
s = a[1:5]
assert len(s) == 4
@@ -688,7 +688,7 @@
assert s[0] == 5
def test_getslice_step(self):
- from numpypy import array
+ from _numpypy import array
a = array(range(10))
s = a[1:9:2]
assert len(s) == 4
@@ -696,7 +696,7 @@
assert s[i] == a[2 * i + 1]
def test_slice_update(self):
- from numpypy import array
+ from _numpypy import array
a = array(range(5))
s = a[0:3]
s[1] = 10
@@ -706,7 +706,7 @@
def test_slice_invaidate(self):
# check that slice shares invalidation list with
- from numpypy import array
+ from _numpypy import array
a = array(range(5))
s = a[0:2]
b = array([10, 11])
@@ -720,13 +720,13 @@
assert d[1] == 12
def test_mean(self):
- from numpypy import array
+ from _numpypy import array
a = array(range(5))
assert a.mean() == 2.0
assert a[:4].mean() == 1.5
def test_sum(self):
- from numpypy import array
+ from _numpypy import array
a = array(range(5))
assert a.sum() == 10.0
assert a[:4].sum() == 6.0
@@ -735,8 +735,8 @@
assert a.sum() == 5
def test_identity(self):
- from numpypy import identity, array
- from numpypy import int32, float64, dtype
+ from _numpypy import identity, array
+ from _numpypy import int32, float64, dtype
a = identity(0)
assert len(a) == 0
assert a.dtype == dtype('float64')
@@ -755,32 +755,32 @@
assert (d == [[1, 0, 0], [0, 1, 0], [0, 0, 1]]).all()
def test_prod(self):
- from numpypy import array
+ from _numpypy import array
a = array(range(1, 6))
assert a.prod() == 120.0
assert a[:4].prod() == 24.0
def test_max(self):
- from numpypy import array
+ from _numpypy import array
a = array([-1.2, 3.4, 5.7, -3.0, 2.7])
assert a.max() == 5.7
b = array([])
raises(ValueError, "b.max()")
def test_max_add(self):
- from numpypy import array
+ from _numpypy import array
a = array([-1.2, 3.4, 5.7, -3.0, 2.7])
assert (a + a).max() == 11.4
def test_min(self):
- from numpypy import array
+ from _numpypy import array
a = array([-1.2, 3.4, 5.7, -3.0, 2.7])
assert a.min() == -3.0
b = array([])
raises(ValueError, "b.min()")
def test_argmax(self):
- from numpypy import array
+ from _numpypy import array
a = array([-1.2, 3.4, 5.7, -3.0, 2.7])
r = a.argmax()
assert r == 2
@@ -801,14 +801,14 @@
assert a.argmax() == 2
def test_argmin(self):
- from numpypy import array
+ from _numpypy import array
a = array([-1.2, 3.4, 5.7, -3.0, 2.7])
assert a.argmin() == 3
b = array([])
raises(ValueError, "b.argmin()")
def test_all(self):
- from numpypy import array
+ from _numpypy import array
a = array(range(5))
assert a.all() == False
a[0] = 3.0
@@ -817,7 +817,7 @@
assert b.all() == True
def test_any(self):
- from numpypy import array, zeros
+ from _numpypy import array, zeros
a = array(range(5))
assert a.any() == True
b = zeros(5)
@@ -826,7 +826,7 @@
assert c.any() == False
def test_dot(self):
- from numpypy import array, dot
+ from _numpypy import array, dot
a = array(range(5))
assert a.dot(a) == 30.0
@@ -836,14 +836,14 @@
assert (dot(5, [1, 2, 3]) == [5, 10, 15]).all()
def test_dot_constant(self):
- from numpypy import array
+ from _numpypy import array
a = array(range(5))
b = a.dot(2.5)
for i in xrange(5):
assert b[i] == 2.5 * a[i]
def test_dtype_guessing(self):
- from numpypy import array, dtype, float64, int8, bool_
+ from _numpypy import array, dtype, float64, int8, bool_
assert array([True]).dtype is dtype(bool)
assert array([True, False]).dtype is dtype(bool)
@@ -860,7 +860,7 @@
def test_comparison(self):
import operator
- from numpypy import array, dtype
+ from _numpypy import array, dtype
a = array(range(5))
b = array(range(5), float)
@@ -879,7 +879,7 @@
assert c[i] == func(b[i], 3)
def test_nonzero(self):
- from numpypy import array
+ from _numpypy import array
a = array([1, 2])
raises(ValueError, bool, a)
raises(ValueError, bool, a == a)
@@ -889,7 +889,7 @@
assert not bool(array([0]))
def test_slice_assignment(self):
- from numpypy import array
+ from _numpypy import array
a = array(range(5))
a[::-1] = a
assert (a == [0, 1, 2, 1, 0]).all()
@@ -899,8 +899,8 @@
assert (a == [8, 6, 4, 2, 0]).all()
def test_debug_repr(self):
- from numpypy import zeros, sin
- from numpypy.pypy import debug_repr
+ from _numpypy import zeros, sin
+ from _numpypy.pypy import debug_repr
a = zeros(1)
assert debug_repr(a) == 'Array'
assert debug_repr(a + a) == 'Call2(add, Array, Array)'
@@ -914,8 +914,8 @@
assert debug_repr(b) == 'Array'
def test_remove_invalidates(self):
- from numpypy import array
- from numpypy.pypy import remove_invalidates
+ from _numpypy import array
+ from _numpypy.pypy import remove_invalidates
a = array([1, 2, 3])
b = a + a
remove_invalidates(a)
@@ -923,7 +923,7 @@
assert b[0] == 28
def test_virtual_views(self):
- from numpypy import arange
+ from _numpypy import arange
a = arange(15)
c = (a + a)
d = c[::2]
@@ -941,7 +941,7 @@
assert b[1] == 2
def test_tolist_scalar(self):
- from numpypy import int32, bool_
+ from _numpypy import int32, bool_
x = int32(23)
assert x.tolist() == 23
assert type(x.tolist()) is int
@@ -949,13 +949,13 @@
assert y.tolist() is True
def test_tolist_zerodim(self):
- from numpypy import array
+ from _numpypy import array
x = array(3)
assert x.tolist() == 3
assert type(x.tolist()) is int
def test_tolist_singledim(self):
- from numpypy import array
+ from _numpypy import array
a = array(range(5))
assert a.tolist() == [0, 1, 2, 3, 4]
assert type(a.tolist()[0]) is int
@@ -963,17 +963,17 @@
assert b.tolist() == [0.2, 0.4, 0.6]
def test_tolist_multidim(self):
- from numpypy import array
+ from _numpypy import array
a = array([[1, 2], [3, 4]])
assert a.tolist() == [[1, 2], [3, 4]]
def test_tolist_view(self):
- from numpypy import array
+ from _numpypy import array
a = array([[1, 2], [3, 4]])
assert (a + a).tolist() == [[2, 4], [6, 8]]
def test_tolist_slice(self):
- from numpypy import array
+ from _numpypy import array
a = array([[17.1, 27.2], [40.3, 50.3]])
assert a[:, 0].tolist() == [17.1, 40.3]
assert a[0].tolist() == [17.1, 27.2]
@@ -981,23 +981,23 @@
class AppTestMultiDim(BaseNumpyAppTest):
def test_init(self):
- import numpypy
- a = numpypy.zeros((2, 2))
+ import _numpypy
+ a = _numpypy.zeros((2, 2))
assert len(a) == 2
def test_shape(self):
- import numpypy
- assert numpypy.zeros(1).shape == (1,)
- assert numpypy.zeros((2, 2)).shape == (2, 2)
- assert numpypy.zeros((3, 1, 2)).shape == (3, 1, 2)
- assert numpypy.array([[1], [2], [3]]).shape == (3, 1)
- assert len(numpypy.zeros((3, 1, 2))) == 3
- raises(TypeError, len, numpypy.zeros(()))
- raises(ValueError, numpypy.array, [[1, 2], 3])
+ import _numpypy
+ assert _numpypy.zeros(1).shape == (1,)
+ assert _numpypy.zeros((2, 2)).shape == (2, 2)
+ assert _numpypy.zeros((3, 1, 2)).shape == (3, 1, 2)
+ assert _numpypy.array([[1], [2], [3]]).shape == (3, 1)
+ assert len(_numpypy.zeros((3, 1, 2))) == 3
+ raises(TypeError, len, _numpypy.zeros(()))
+ raises(ValueError, _numpypy.array, [[1, 2], 3])
def test_getsetitem(self):
- import numpypy
- a = numpypy.zeros((2, 3, 1))
+ import _numpypy
+ a = _numpypy.zeros((2, 3, 1))
raises(IndexError, a.__getitem__, (2, 0, 0))
raises(IndexError, a.__getitem__, (0, 3, 0))
raises(IndexError, a.__getitem__, (0, 0, 1))
@@ -1008,8 +1008,8 @@
assert a[1, -1, 0] == 3
def test_slices(self):
- import numpypy
- a = numpypy.zeros((4, 3, 2))
+ import _numpypy
+ a = _numpypy.zeros((4, 3, 2))
raises(IndexError, a.__getitem__, (4,))
raises(IndexError, a.__getitem__, (3, 3))
raises(IndexError, a.__getitem__, (slice(None), 3))
@@ -1042,51 +1042,51 @@
assert a[1][2][1] == 15
def test_init_2(self):
- import numpypy
- raises(ValueError, numpypy.array, [[1], 2])
- raises(ValueError, numpypy.array, [[1, 2], [3]])
- raises(ValueError, numpypy.array, [[[1, 2], [3, 4], 5]])
- raises(ValueError, numpypy.array, [[[1, 2], [3, 4], [5]]])
- a = numpypy.array([[1, 2], [4, 5]])
+ import _numpypy
+ raises(ValueError, _numpypy.array, [[1], 2])
+ raises(ValueError, _numpypy.array, [[1, 2], [3]])
+ raises(ValueError, _numpypy.array, [[[1, 2], [3, 4], 5]])
+ raises(ValueError, _numpypy.array, [[[1, 2], [3, 4], [5]]])
+ a = _numpypy.array([[1, 2], [4, 5]])
assert a[0, 1] == 2
assert a[0][1] == 2
- a = numpypy.array(([[[1, 2], [3, 4], [5, 6]]]))
+ a = _numpypy.array(([[[1, 2], [3, 4], [5, 6]]]))
assert (a[0, 1] == [3, 4]).all()
def test_setitem_slice(self):
- import numpypy
- a = numpypy.zeros((3, 4))
+ import _numpypy
+ a = _numpypy.zeros((3, 4))
a[1] = [1, 2, 3, 4]
assert a[1, 2] == 3
raises(TypeError, a[1].__setitem__, [1, 2, 3])
- a = numpypy.array([[1, 2], [3, 4]])
+ a = _numpypy.array([[1, 2], [3, 4]])
assert (a == [[1, 2], [3, 4]]).all()
- a[1] = numpypy.array([5, 6])
+ a[1] = _numpypy.array([5, 6])
assert (a == [[1, 2], [5, 6]]).all()
- a[:, 1] = numpypy.array([8, 10])
+ a[:, 1] = _numpypy.array([8, 10])
assert (a == [[1, 8], [5, 10]]).all()
- a[0, :: -1] = numpypy.array([11, 12])
+ a[0, :: -1] = _numpypy.array([11, 12])
assert (a == [[12, 11], [5, 10]]).all()
def test_ufunc(self):
- from numpypy import array
+ from _numpypy import array
a = array([[1, 2], [3, 4], [5, 6]])
assert ((a + a) == \
array([[1 + 1, 2 + 2], [3 + 3, 4 + 4], [5 + 5, 6 + 6]])).all()
def test_getitem_add(self):
- from numpypy import array
+ from _numpypy import array
a = array([[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]])
assert (a + a)[1, 1] == 8
def test_ufunc_negative(self):
- from numpypy import array, negative
+ from _numpypy import array, negative
a = array([[1, 2], [3, 4]])
b = negative(a + a)
assert (b == [[-2, -4], [-6, -8]]).all()
def test_getitem_3(self):
- from numpypy import array
+ from _numpypy import array
a = array([[1, 2], [3, 4], [5, 6], [7, 8],
[9, 10], [11, 12], [13, 14]])
b = a[::2]
@@ -1097,12 +1097,12 @@
assert c[1][1] == 12
def test_multidim_ones(self):
- from numpypy import ones
+ from _numpypy import ones
a = ones((1, 2, 3))
assert a[0, 1, 2] == 1.0
def test_multidim_setslice(self):
- from numpypy import zeros, ones
+ from _numpypy import zeros, ones
a = zeros((3, 3))
b = ones((3, 3))
a[:, 1:3] = b[:, 1:3]
@@ -1113,21 +1113,21 @@
assert (a == [[1, 0, 1], [1, 0, 1], [1, 0, 1]]).all()
def test_broadcast_ufunc(self):
- from numpypy import array
+ from _numpypy import array
a = array([[1, 2], [3, 4], [5, 6]])
b = array([5, 6])
c = ((a + b) == [[1 + 5, 2 + 6], [3 + 5, 4 + 6], [5 + 5, 6 + 6]])
assert c.all()
def test_broadcast_setslice(self):
- from numpypy import zeros, ones
+ from _numpypy import zeros, ones
a = zeros((10, 10))
b = ones(10)
a[:, :] = b
assert a[3, 5] == 1
def test_broadcast_shape_agreement(self):
- from numpypy import zeros, array
+ from _numpypy import zeros, array
a = zeros((3, 1, 3))
b = array(((10, 11, 12), (20, 21, 22), (30, 31, 32)))
c = ((a + b) == [b, b, b])
@@ -1141,7 +1141,7 @@
assert c.all()
def test_broadcast_scalar(self):
- from numpypy import zeros
+ from _numpypy import zeros
a = zeros((4, 5), 'd')
a[:, 1] = 3
assert a[2, 1] == 3
@@ -1152,14 +1152,14 @@
assert a[3, 2] == 0
def test_broadcast_call2(self):
- from numpypy import zeros, ones
+ from _numpypy import zeros, ones
a = zeros((4, 1, 5))
b = ones((4, 3, 5))
b[:] = (a + a)
assert (b == zeros((4, 3, 5))).all()
def test_broadcast_virtualview(self):
- from numpypy import arange, zeros
+ from _numpypy import arange, zeros
a = arange(8).reshape([2, 2, 2])
b = (a + a)[1, 1]
c = zeros((2, 2, 2))
@@ -1167,13 +1167,13 @@
assert (c == [[[12, 14], [12, 14]], [[12, 14], [12, 14]]]).all()
def test_argmax(self):
- from numpypy import array
+ from _numpypy import array
a = array([[1, 2], [3, 4], [5, 6]])
assert a.argmax() == 5
assert a[:2, ].argmax() == 3
def test_broadcast_wrong_shapes(self):
- from numpypy import zeros
+ from _numpypy import zeros
a = zeros((4, 3, 2))
b = zeros((4, 2))
exc = raises(ValueError, lambda: a + b)
@@ -1181,7 +1181,7 @@
" together with shapes (4,3,2) (4,2)"
def test_reduce(self):
- from numpypy import array
+ from _numpypy import array
a = array([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]])
assert a.sum() == (13 * 12) / 2
b = a[1:, 1::2]
@@ -1189,7 +1189,7 @@
assert c.sum() == (6 + 8 + 10 + 12) * 2
def test_transpose(self):
- from numpypy import array
+ from _numpypy import array
a = array(((range(3), range(3, 6)),
(range(6, 9), range(9, 12)),
(range(12, 15), range(15, 18)),
@@ -1208,7 +1208,7 @@
assert(b[:, 0] == a[0, :]).all()
def test_flatiter(self):
- from numpypy import array, flatiter
+ from _numpypy import array, flatiter
a = array([[10, 30], [40, 60]])
f_iter = a.flat
assert f_iter.next() == 10
@@ -1223,23 +1223,23 @@
assert s == 140
def test_flatiter_array_conv(self):
- from numpypy import array, dot
+ from _numpypy import array, dot
a = array([1, 2, 3])
assert dot(a.flat, a.flat) == 14
def test_flatiter_varray(self):
- from numpypy import ones
+ from _numpypy import ones
a = ones((2, 2))
assert list(((a + a).flat)) == [2, 2, 2, 2]
def test_slice_copy(self):
- from numpypy import zeros
+ from _numpypy import zeros
a = zeros((10, 10))
b = a[0].copy()
assert (b == zeros(10)).all()
def test_array_interface(self):
- from numpypy import array
+ from _numpypy import array
a = array([1, 2, 3])
i = a.__array_interface__
assert isinstance(i['data'][0], int)
@@ -1261,7 +1261,7 @@
def test_fromstring(self):
import sys
- from numpypy import fromstring, array, uint8, float32, int32
+ from _numpypy import fromstring, array, uint8, float32, int32
a = fromstring(self.data)
for i in range(4):
@@ -1325,7 +1325,7 @@
assert (u == [1, 0]).all()
def test_fromstring_types(self):
- from numpypy import (fromstring, int8, int16, int32, int64, uint8,
+ from _numpypy import (fromstring, int8, int16, int32, int64, uint8,
uint16, uint32, float32, float64)
a = fromstring('\xFF', dtype=int8)
@@ -1350,7 +1350,7 @@
assert j[0] == 12
def test_fromstring_invalid(self):
- from numpypy import fromstring, uint16, uint8, int32
+ from _numpypy import fromstring, uint16, uint8, int32
#default dtype is 64-bit float, so 3 bytes should fail
raises(ValueError, fromstring, "\x01\x02\x03")
#3 bytes is not modulo 2 bytes (int16)
@@ -1361,7 +1361,7 @@
class AppTestRepr(BaseNumpyAppTest):
def test_repr(self):
- from numpypy import array, zeros
+ from _numpypy import array, zeros
int_size = array(5).dtype.itemsize
a = array(range(5), float)
assert repr(a) == "array([0.0, 1.0, 2.0, 3.0, 4.0])"
@@ -1389,7 +1389,7 @@
assert repr(a) == "array(0.2)"
def test_repr_multi(self):
- from numpypy import arange, zeros
+ from _numpypy import arange, zeros
a = zeros((3, 4))
assert repr(a) == '''array([[0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 0.0],
@@ -1414,7 +1414,7 @@
[500, 1001]])'''
def test_repr_slice(self):
- from numpypy import array, zeros
+ from _numpypy import array, zeros
a = array(range(5), float)
b = a[1::2]
assert repr(b) == "array([1.0, 3.0])"
@@ -1429,7 +1429,7 @@
assert repr(b) == "array([], shape=(0, 5), dtype=int16)"
def test_str(self):
- from numpypy import array, zeros
+ from _numpypy import array, zeros
a = array(range(5), float)
assert str(a) == "[0.0 1.0 2.0 3.0 4.0]"
assert str((2 * a)[:]) == "[0.0 2.0 4.0 6.0 8.0]"
@@ -1462,7 +1462,7 @@
assert r == '[[[0.0 0.0]\n [0.0 0.0]]\n\n [[0.0 0.0]\n [0.0 0.0]]]'
def test_str_slice(self):
- from numpypy import array, zeros
+ from _numpypy import array, zeros
a = array(range(5), float)
b = a[1::2]
assert str(b) == "[1.0 3.0]"
@@ -1478,7 +1478,7 @@
class AppTestRanges(BaseNumpyAppTest):
def test_arange(self):
- from numpypy import arange, array, dtype
+ from _numpypy import arange, array, dtype
a = arange(3)
assert (a == [0, 1, 2]).all()
assert a.dtype is dtype(int)
@@ -1500,7 +1500,7 @@
class AppTestRanges(BaseNumpyAppTest):
def test_app_reshape(self):
- from numpypy import arange, array, dtype, reshape
+ from _numpypy import arange, array, dtype, reshape
a = arange(12)
b = reshape(a, (3, 4))
assert b.shape == (3, 4)
diff --git a/pypy/module/micronumpy/test/test_ufuncs.py b/pypy/module/micronumpy/test/test_ufuncs.py
--- a/pypy/module/micronumpy/test/test_ufuncs.py
+++ b/pypy/module/micronumpy/test/test_ufuncs.py
@@ -4,14 +4,14 @@
class AppTestUfuncs(BaseNumpyAppTest):
def test_ufunc_instance(self):
- from numpypy import add, ufunc
+ from _numpypy import add, ufunc
assert isinstance(add, ufunc)
assert repr(add) == "<ufunc 'add'>"
assert repr(ufunc) == "<type 'numpypy.ufunc'>"
def test_ufunc_attrs(self):
- from numpypy import add, multiply, sin
+ from _numpypy import add, multiply, sin
assert add.identity == 0
assert multiply.identity == 1
@@ -22,7 +22,7 @@
assert sin.nin == 1
def test_wrong_arguments(self):
- from numpypy import add, sin
+ from _numpypy import add, sin
raises(ValueError, add, 1)
raises(TypeError, add, 1, 2, 3)
@@ -30,14 +30,14 @@
raises(ValueError, sin)
def test_single_item(self):
- from numpypy import negative, sign, minimum
+ from _numpypy import negative, sign, minimum
assert negative(5.0) == -5.0
assert sign(-0.0) == 0.0
assert minimum(2.0, 3.0) == 2.0
def test_sequence(self):
- from numpypy import array, ndarray, negative, minimum
+ from _numpypy import array, ndarray, negative, minimum
a = array(range(3))
b = [2.0, 1.0, 0.0]
c = 1.0
@@ -71,7 +71,7 @@
assert min_c_b[i] == min(b[i], c)
def test_negative(self):
- from numpypy import array, negative
+ from _numpypy import array, negative
a = array([-5.0, 0.0, 1.0])
b = negative(a)
@@ -86,7 +86,7 @@
assert negative(a + a)[3] == -6
def test_abs(self):
- from numpypy import array, absolute
+ from _numpypy import array, absolute
a = array([-5.0, -0.0, 1.0])
b = absolute(a)
@@ -94,7 +94,7 @@
assert b[i] == abs(a[i])
def test_add(self):
- from numpypy import array, add
+ from _numpypy import array, add
a = array([-5.0, -0.0, 1.0])
b = array([ 3.0, -2.0,-3.0])
@@ -103,7 +103,7 @@
assert c[i] == a[i] + b[i]
def test_divide(self):
- from numpypy import array, divide
+ from _numpypy import array, divide
a = array([-5.0, -0.0, 1.0])
b = array([ 3.0, -2.0,-3.0])
@@ -114,7 +114,7 @@
assert (divide(array([-10]), array([2])) == array([-5])).all()
def test_fabs(self):
- from numpypy import array, fabs
+ from _numpypy import array, fabs
from math import fabs as math_fabs
a = array([-5.0, -0.0, 1.0])
@@ -123,7 +123,7 @@
assert b[i] == math_fabs(a[i])
def test_minimum(self):
- from numpypy import array, minimum
+ from _numpypy import array, minimum
a = array([-5.0, -0.0, 1.0])
b = array([ 3.0, -2.0,-3.0])
@@ -132,7 +132,7 @@
assert c[i] == min(a[i], b[i])
def test_maximum(self):
- from numpypy import array, maximum
+ from _numpypy import array, maximum
a = array([-5.0, -0.0, 1.0])
b = array([ 3.0, -2.0,-3.0])
@@ -145,7 +145,7 @@
assert isinstance(x, (int, long))
def test_multiply(self):
- from numpypy import array, multiply
+ from _numpypy import array, multiply
a = array([-5.0, -0.0, 1.0])
b = array([ 3.0, -2.0,-3.0])
@@ -154,7 +154,7 @@
assert c[i] == a[i] * b[i]
def test_sign(self):
- from numpypy import array, sign, dtype
+ from _numpypy import array, sign, dtype
reference = [-1.0, 0.0, 0.0, 1.0]
a = array([-5.0, -0.0, 0.0, 6.0])
@@ -173,7 +173,7 @@
assert a[1] == 0
def test_reciporocal(self):
- from numpypy import array, reciprocal
+ from _numpypy import array, reciprocal
reference = [-0.2, float("inf"), float("-inf"), 2.0]
a = array([-5.0, 0.0, -0.0, 0.5])
@@ -182,7 +182,7 @@
assert b[i] == reference[i]
def test_subtract(self):
- from numpypy import array, subtract
+ from _numpypy import array, subtract
a = array([-5.0, -0.0, 1.0])
b = array([ 3.0, -2.0,-3.0])
@@ -191,7 +191,7 @@
assert c[i] == a[i] - b[i]
def test_floor(self):
- from numpypy import array, floor
+ from _numpypy import array, floor
reference = [-2.0, -1.0, 0.0, 1.0, 1.0]
a = array([-1.4, -1.0, 0.0, 1.0, 1.4])
@@ -200,7 +200,7 @@
assert b[i] == reference[i]
def test_copysign(self):
- from numpypy import array, copysign
+ from _numpypy import array, copysign
reference = [5.0, -0.0, 0.0, -6.0]
a = array([-5.0, 0.0, 0.0, 6.0])
@@ -216,7 +216,7 @@
def test_exp(self):
import math
- from numpypy import array, exp
+ from _numpypy import array, exp
a = array([-5.0, -0.0, 0.0, 12345678.0, float("inf"),
-float('inf'), -12343424.0])
@@ -230,7 +230,7 @@
def test_sin(self):
import math
- from numpypy import array, sin
+ from _numpypy import array, sin
a = array([0, 1, 2, 3, math.pi, math.pi*1.5, math.pi*2])
b = sin(a)
@@ -243,7 +243,7 @@
def test_cos(self):
import math
- from numpypy import array, cos
+ from _numpypy import array, cos
a = array([0, 1, 2, 3, math.pi, math.pi*1.5, math.pi*2])
b = cos(a)
@@ -252,7 +252,7 @@
def test_tan(self):
import math
- from numpypy import array, tan
+ from _numpypy import array, tan
a = array([0, 1, 2, 3, math.pi, math.pi*1.5, math.pi*2])
b = tan(a)
@@ -262,7 +262,7 @@
def test_arcsin(self):
import math
- from numpypy import array, arcsin
+ from _numpypy import array, arcsin
a = array([-1, -0.5, -0.33, 0, 0.33, 0.5, 1])
b = arcsin(a)
@@ -276,7 +276,7 @@
def test_arccos(self):
import math
- from numpypy import array, arccos
+ from _numpypy import array, arccos
a = array([-1, -0.5, -0.33, 0, 0.33, 0.5, 1])
b = arccos(a)
@@ -291,7 +291,7 @@
def test_arctan(self):
import math
- from numpypy import array, arctan
+ from _numpypy import array, arctan
a = array([-3, -2, -1, 0, 1, 2, 3, float('inf'), float('-inf')])
b = arctan(a)
@@ -304,7 +304,7 @@
def test_arcsinh(self):
import math
- from numpypy import arcsinh, inf
+ from _numpypy import arcsinh, inf
for v in [inf, -inf, 1.0, math.e]:
assert math.asinh(v) == arcsinh(v)
@@ -312,7 +312,7 @@
def test_arctanh(self):
import math
- from numpypy import arctanh
+ from _numpypy import arctanh
for v in [.99, .5, 0, -.5, -.99]:
assert math.atanh(v) == arctanh(v)
@@ -323,7 +323,7 @@
def test_sqrt(self):
import math
- from numpypy import sqrt
+ from _numpypy import sqrt
nan, inf = float("nan"), float("inf")
data = [1, 2, 3, inf]
@@ -333,13 +333,13 @@
assert math.isnan(sqrt(nan))
def test_reduce_errors(self):
- from numpypy import sin, add
+ from _numpypy import sin, add
raises(ValueError, sin.reduce, [1, 2, 3])
raises(TypeError, add.reduce, 1)
def test_reduce(self):
- from numpypy import add, maximum
+ from _numpypy import add, maximum
assert add.reduce([1, 2, 3]) == 6
assert maximum.reduce([1]) == 1
@@ -348,7 +348,7 @@
def test_comparisons(self):
import operator
- from numpypy import equal, not_equal, less, less_equal, greater, greater_equal
+ from _numpypy import equal, not_equal, less, less_equal, greater, greater_equal
for ufunc, func in [
(equal, operator.eq),
More information about the pypy-commit
mailing list