[pypy-commit] pypy default: merge heads

arigo noreply at buildbot.pypy.org
Mon Feb 25 22:18:58 CET 2013


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r61796:c2d0d65fbaa9
Date: 2013-02-25 22:18 +0100
http://bitbucket.org/pypy/pypy/changeset/c2d0d65fbaa9/

Log:	merge heads

diff too long, truncating to 2000 out of 4023 lines

diff --git a/.hgignore b/.hgignore
--- a/.hgignore
+++ b/.hgignore
@@ -35,39 +35,43 @@
 ^pypy/doc/config/.+\.rst$
 ^pypy/doc/basicblock\.asc$
 ^pypy/doc/.+\.svninfo$
-^pypy/translator/c/src/libffi_msvc/.+\.obj$
-^pypy/translator/c/src/libffi_msvc/.+\.dll$
-^pypy/translator/c/src/libffi_msvc/.+\.lib$
-^pypy/translator/c/src/libffi_msvc/.+\.exp$
-^pypy/translator/c/src/cjkcodecs/.+\.o$
-^pypy/translator/c/src/cjkcodecs/.+\.obj$
-^pypy/translator/jvm/\.project$
-^pypy/translator/jvm/\.classpath$
-^pypy/translator/jvm/eclipse-bin$
-^pypy/translator/jvm/src/pypy/.+\.class$
-^pypy/translator/benchmark/docutils$
-^pypy/translator/benchmark/templess$
-^pypy/translator/benchmark/gadfly$
-^pypy/translator/benchmark/mako$
-^pypy/translator/benchmark/bench-custom\.benchmark_result$
-^pypy/translator/benchmark/shootout_benchmarks$
-^pypy/translator/goal/pypy-translation-snapshot$
-^pypy/translator/goal/pypy-c
-^pypy/translator/goal/pypy-jvm
-^pypy/translator/goal/pypy-jvm.jar
-^pypy/translator/goal/.+\.exe$
-^pypy/translator/goal/.+\.dll$
-^pypy/translator/goal/target.+-c$
+^rpython/translator/c/src/libffi_msvc/.+\.obj$
+^rpython/translator/c/src/libffi_msvc/.+\.dll$
+^rpython/translator/c/src/libffi_msvc/.+\.lib$
+^rpython/translator/c/src/libffi_msvc/.+\.exp$
+^rpython/translator/c/src/cjkcodecs/.+\.o$
+^rpython/translator/c/src/cjkcodecs/.+\.obj$
+^rpython/translator/c/src/stacklet/.+\.o$
+^rpython/translator/c/src/.+\.o$
+^rpython/translator/jvm/\.project$
+^rpython/translator/jvm/\.classpath$
+^rpython/translator/jvm/eclipse-bin$
+^rpython/translator/jvm/src/pypy/.+\.class$
+^rpython/translator/benchmark/docutils$
+^rpython/translator/benchmark/templess$
+^rpython/translator/benchmark/gadfly$
+^rpython/translator/benchmark/mako$
+^rpython/translator/benchmark/bench-custom\.benchmark_result$
+^rpython/translator/benchmark/shootout_benchmarks$
+^rpython/translator/goal/target.+-c$
+^rpython/translator/goal/.+\.exe$
+^rpython/translator/goal/.+\.dll$
+^pypy/goal/pypy-translation-snapshot$
+^pypy/goal/pypy-c
+^pypy/goal/pypy-jvm
+^pypy/goal/pypy-jvm.jar
+^pypy/goal/.+\.exe$
+^pypy/goal/.+\.dll$
 ^pypy/_cache$
 ^pypy/doc/statistic/.+\.html$
 ^pypy/doc/statistic/.+\.eps$
 ^pypy/doc/statistic/.+\.pdf$
-^pypy/translator/cli/src/pypylib\.dll$
-^pypy/translator/cli/src/query\.exe$
-^pypy/translator/cli/src/main\.exe$
+^rpython/translator/cli/src/pypylib\.dll$
+^rpython/translator/cli/src/query\.exe$
+^rpython/translator/cli/src/main\.exe$
 ^lib_pypy/ctypes_config_cache/_.+_cache\.py$
 ^lib_pypy/ctypes_config_cache/_.+_.+_\.py$
-^pypy/translator/cli/query-descriptions$
+^rpython/translator/cli/query-descriptions$
 ^pypy/doc/discussion/.+\.html$
 ^include/.+\.h$
 ^include/.+\.inl$
diff --git a/lib_pypy/numpypy/core/__init__.py b/lib_pypy/numpypy/core/__init__.py
--- a/lib_pypy/numpypy/core/__init__.py
+++ b/lib_pypy/numpypy/core/__init__.py
@@ -1,18 +1,14 @@
-import _numpypy
-from _numpypy import *
 import numeric
 from numeric import *
 import fromnumeric
 from fromnumeric import *
 import shape_base
 from shape_base import *
-import multiarray
 
 from fromnumeric import amax as max, amin as min
-from _numpypy import absolute as abs
+from numeric import absolute as abs
 
 __all__ = []
-__all__ += _numpypy.__all__
 __all__ += numeric.__all__
 __all__ += fromnumeric.__all__
 __all__ += shape_base.__all__
diff --git a/lib_pypy/numpypy/core/_methods.py b/lib_pypy/numpypy/core/_methods.py
--- a/lib_pypy/numpypy/core/_methods.py
+++ b/lib_pypy/numpypy/core/_methods.py
@@ -1,11 +1,9 @@
 # Array methods which are called by the both the C-code for the method
 # and the Python code for the NumPy-namespace function
 
-#from numpy.core import multiarray as mu
-#from numpy.core import umath as um
-import _numpypy as mu
-um = mu
-from numpy.core.numeric import asanyarray
+import multiarray as mu
+import umath as um
+from numeric import asanyarray
 
 def _amax(a, axis=None, out=None, keepdims=False):
     return um.maximum.reduce(a, axis=axis,
diff --git a/lib_pypy/numpypy/core/arrayprint.py b/lib_pypy/numpypy/core/arrayprint.py
--- a/lib_pypy/numpypy/core/arrayprint.py
+++ b/lib_pypy/numpypy/core/arrayprint.py
@@ -13,9 +13,9 @@
 # and by Travis Oliphant  2005-8-22 for numpy
 
 import sys
-import _numpypy as _nt
-from _numpypy import maximum, minimum, absolute, not_equal, isnan, isinf
-#from _numpypy import format_longfloat, datetime_as_string, datetime_data
+import numerictypes as _nt
+from umath import maximum, minimum, absolute, not_equal, isnan, isinf
+#from multiarray import format_longfloat, datetime_as_string, datetime_data
 from fromnumeric import ravel
 
 
diff --git a/lib_pypy/numpypy/core/fromnumeric.py b/lib_pypy/numpypy/core/fromnumeric.py
--- a/lib_pypy/numpypy/core/fromnumeric.py
+++ b/lib_pypy/numpypy/core/fromnumeric.py
@@ -16,6 +16,7 @@
 ######################################################################
 
 import numpypy
+import _numpypy
 
 # Module containing non-deprecated functions borrowed from Numeric.
 __docformat__ = "restructuredtext en"
@@ -274,7 +275,7 @@
             [-1, -2, -3, -4, -5]]])
 
     """
-    raise NotImplementedError('Waiting on interp level method')
+    return _numpypy.choose(a, choices, out, mode)
 
 
 def repeat(a, repeats, axis=None):
@@ -316,7 +317,7 @@
            [3, 4]])
 
     """
-    raise NotImplementedError('Waiting on interp level method')
+    return _numpypy.repeat(a, repeats, axis)
 
 
 def put(a, ind, v, mode='raise'):
diff --git a/lib_pypy/numpypy/core/multiarray.py b/lib_pypy/numpypy/core/multiarray.py
--- a/lib_pypy/numpypy/core/multiarray.py
+++ b/lib_pypy/numpypy/core/multiarray.py
@@ -1,1 +1,1 @@
-from _numpypy import set_string_function, typeinfo
+from _numpypy.multiarray import *
diff --git a/lib_pypy/numpypy/core/numeric.py b/lib_pypy/numpypy/core/numeric.py
--- a/lib_pypy/numpypy/core/numeric.py
+++ b/lib_pypy/numpypy/core/numeric.py
@@ -1,16 +1,40 @@
-__all__ = ['asanyarray', 'base_repr',
+__all__ = [
+           'newaxis', 'ufunc',
+           'asarray', 'asanyarray', 'base_repr',
            'array_repr', 'array_str', 'set_string_function',
-           'array_equal', 'asarray', 'outer', 'identity']
+           'array_equal', 'outer', 'identity', 'little_endian',
+           'Inf', 'inf', 'infty', 'Infinity', 'nan', 'NaN', 'False_', 'True_',
+          ]
 
-from _numpypy import array, ndarray, int_, float_, bool_, flexible #, complex_# , longlong
-from _numpypy import concatenate
-from .fromnumeric import any
-import math
 import sys
 import multiarray
-from numpypy.core.arrayprint import array2string
+from multiarray import *
+del set_string_function
+del typeinfo
+import umath
+from umath import *
+import numerictypes
+from numerictypes import *
+
+def extend_all(module):
+    adict = {}
+    for a in __all__:
+        adict[a] = 1
+    try:
+        mall = getattr(module, '__all__')
+    except AttributeError:
+        mall = [k for k in module.__dict__.keys() if not k.startswith('_')]
+    for a in mall:
+        if a not in adict:
+            __all__.append(a)
+
+extend_all(multiarray)
+__all__.remove('typeinfo')
+extend_all(umath)
+extend_all(numerictypes)
 
 newaxis = None
+ufunc = type(sin)
 
 # XXX this file to be reviewed
 def seterr(**args):
@@ -121,6 +145,10 @@
         res.append('-')
     return ''.join(reversed(res or '0'))
 
+
+#Use numarray's printing function
+from arrayprint import array2string
+
 _typelessdata = [int_, float_]#, complex_]
 # XXX
 #if issubclass(intc, int):
@@ -306,6 +334,11 @@
     else:
         return multiarray.set_string_function(f, repr)
 
+set_string_function(array_str, 0)
+set_string_function(array_repr, 1)
+
+little_endian = (sys.byteorder == 'little')
+
 def array_equal(a1, a2):
     """
     True if two arrays have the same shape and elements, False otherwise.
@@ -417,21 +450,6 @@
     """
     return array(a, dtype, copy=False, order=order)
 
-set_string_function(array_str, 0)
-set_string_function(array_repr, 1)
-
-little_endian = (sys.byteorder == 'little')
-
-Inf = inf = infty = Infinity = PINF = float('inf')
-NINF = float('-inf')
-PZERO = 0.0
-NZERO = -0.0
-nan = NaN = NAN = float('nan')
-False_ = bool_(False)
-True_ = bool_(True)
-e = math.e
-pi = math.pi
-
 def outer(a,b):
     """
     Compute the outer product of two vectors.
@@ -535,3 +553,12 @@
     """
     from numpy import eye
     return eye(n, dtype=dtype)
+
+Inf = inf = infty = Infinity = PINF
+nan = NaN = NAN
+False_ = bool_(False)
+True_ = bool_(True)
+
+import fromnumeric
+from fromnumeric import *
+extend_all(fromnumeric)
diff --git a/lib_pypy/numpypy/core/numerictypes.py b/lib_pypy/numpypy/core/numerictypes.py
new file mode 100644
--- /dev/null
+++ b/lib_pypy/numpypy/core/numerictypes.py
@@ -0,0 +1,1 @@
+from _numpypy.numerictypes import *
diff --git a/lib_pypy/numpypy/core/shape_base.py b/lib_pypy/numpypy/core/shape_base.py
--- a/lib_pypy/numpypy/core/shape_base.py
+++ b/lib_pypy/numpypy/core/shape_base.py
@@ -1,6 +1,6 @@
 __all__ = ['atleast_1d', 'atleast_2d', 'atleast_3d', 'vstack', 'hstack']
 
-import _numpypy
+import numeric as _nx
 from numeric import array, asanyarray, newaxis
 
 def atleast_1d(*arys):
@@ -223,7 +223,7 @@
            [4]])
 
     """
-    return _numpypy.concatenate(map(atleast_2d,tup),0)
+    return _nx.concatenate(map(atleast_2d,tup),0)
 
 def hstack(tup):
     """
@@ -270,6 +270,6 @@
     arrs = map(atleast_1d,tup)
     # As a special case, dimension 0 of 1-dimensional arrays is "horizontal"
     if arrs[0].ndim == 1:
-        return _numpypy.concatenate(arrs, 0)
+        return _nx.concatenate(arrs, 0)
     else:
-        return _numpypy.concatenate(arrs, 1)
+        return _nx.concatenate(arrs, 1)
diff --git a/lib_pypy/numpypy/core/umath.py b/lib_pypy/numpypy/core/umath.py
new file mode 100644
--- /dev/null
+++ b/lib_pypy/numpypy/core/umath.py
@@ -0,0 +1,12 @@
+from _numpypy.umath import *
+
+import math
+e = math.e
+pi = math.pi
+del math
+
+PZERO = 0.0
+NZERO = -0.0
+PINF = float('inf')
+NINF = float('-inf')
+NAN = float('nan')
diff --git a/lib_pypy/numpypy/lib/function_base.py b/lib_pypy/numpypy/lib/function_base.py
--- a/lib_pypy/numpypy/lib/function_base.py
+++ b/lib_pypy/numpypy/lib/function_base.py
@@ -1,6 +1,6 @@
 __all__ = ['average']
 
-from _numpypy import array
+from ..core.numeric import array
 
 def average(a):
     # This implements a weighted average, for now we don't implement the
diff --git a/lib_pypy/numpypy/lib/shape_base.py b/lib_pypy/numpypy/lib/shape_base.py
--- a/lib_pypy/numpypy/lib/shape_base.py
+++ b/lib_pypy/numpypy/lib/shape_base.py
@@ -1,7 +1,7 @@
 __all__ = ['dstack']
 
-import numpypy.core.numeric as _nx
-from numpypy.core import atleast_3d
+from ..core import numeric as _nx
+from ..core import atleast_3d
 
 def dstack(tup):
     """
diff --git a/lib_pypy/numpypy/lib/twodim_base.py b/lib_pypy/numpypy/lib/twodim_base.py
--- a/lib_pypy/numpypy/lib/twodim_base.py
+++ b/lib_pypy/numpypy/lib/twodim_base.py
@@ -1,6 +1,6 @@
 __all__ = ['eye']
 
-from _numpypy import zeros
+from ..core.numeric import zeros
 
 def eye(N, M=None, k=0, dtype=float):
     """
diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -75,3 +75,6 @@
 
 .. branch: enumerate-rstr
 Support enumerate() over rstr types.
+
+.. branch: cleanup-numpypy-namespace
+Cleanup _numpypy and numpypy namespaces to more closely resemble numpy.
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
@@ -2,13 +2,11 @@
 from pypy.module.micronumpy.interp_boxes import long_double_size, ENABLED_LONG_DOUBLE
 
 
-class Module(MixedModule):
-    applevel_name = '_numpypy'
-
+class MultiArrayModule(MixedModule):
+    appleveldefs = {'arange': 'app_numpy.arange'}
     interpleveldefs = {
         'ndarray': 'interp_numarray.W_NDimArray',
         'dtype': 'interp_dtype.W_Dtype',
-        'ufunc': 'interp_ufuncs.W_Ufunc',
 
         'array': 'interp_numarray.array',
         'zeros': 'interp_numarray.zeros',
@@ -18,17 +16,17 @@
         'fromstring': 'interp_support.fromstring',
         'flatiter': 'interp_flatiter.W_FlatIterator',
         'concatenate': 'interp_arrayops.concatenate',
-        'repeat': 'interp_arrayops.repeat',
         'where': 'interp_arrayops.where',
         'count_nonzero': 'interp_arrayops.count_nonzero',
 
         'set_string_function': 'appbridge.set_string_function',
+        'typeinfo': 'interp_dtype.get_dtype_cache(space).w_typeinfo',
+    }
 
-        'True_': 'types.Bool.True',
-        'False_': 'types.Bool.False',
 
-        'typeinfo': 'interp_dtype.get_dtype_cache(space).w_typeinfo',
-
+class NumericTypesModule(MixedModule):
+    appleveldefs = {}
+    interpleveldefs = {
         'generic': 'interp_boxes.W_GenericBox',
         'number': 'interp_boxes.W_NumberBox',
         'integer': 'interp_boxes.W_IntegerBox',
@@ -72,7 +70,30 @@
         'complex128': 'interp_boxes.W_Complex128Box',
         'complex64': 'interp_boxes.W_Complex64Box',
     }
+    if ENABLED_LONG_DOUBLE:
+        long_double_dtypes = [
+            ('longdouble', 'interp_boxes.W_LongDoubleBox'),
+            ('longfloat', 'interp_boxes.W_LongDoubleBox'),
+            ('clongdouble', 'interp_boxes.W_CLongDoubleBox'),
+            ('clongfloat', 'interp_boxes.W_CLongDoubleBox'),
+        ]
+        if long_double_size == 16:
+            long_double_dtypes += [
+                ('float128', 'interp_boxes.W_Float128Box'),
+                ('complex256', 'interp_boxes.W_Complex256Box'),
+            ]
+        elif long_double_size == 12:
+            long_double_dtypes += [
+                ('float96', 'interp_boxes.W_Float96Box'),
+                ('complex192', 'interp_boxes.W_Complex192Box'),
+            ]
+        for dt, box in long_double_dtypes:
+            interpleveldefs[dt] = box
 
+
+class UMathModule(MixedModule):
+    appleveldefs = {}
+    interpleveldefs = {}
     # ufuncs
     for exposed, impl in [
         ("absolute", "absolute"),
@@ -154,35 +175,16 @@
     ]:
         interpleveldefs[exposed] = "interp_ufuncs.get(space).%s" % impl
 
-    appleveldefs = {
-        'arange': 'app_numpy.arange',
+
+class Module(MixedModule):
+    applevel_name = '_numpypy'
+    appleveldefs = {}
+    interpleveldefs = {
+        'choose': 'interp_arrayops.choose',
+        'repeat': 'interp_arrayops.repeat',
     }
-    def setup_after_space_initialization(self):
-        space = self.space
-        all_list = sorted(Module.interpleveldefs.keys() + \
-                                Module.appleveldefs.keys())
-        # found by set(numpypy.__all__) - set(numpy.__all__)
-        all_list.remove('set_string_function')
-        all_list.remove('typeinfo')
-        w_all = space.wrap(all_list)
-        space.setitem(self.w_dict, space.new_interned_str('__all__'), w_all)
-
-if ENABLED_LONG_DOUBLE:
-    long_double_dtypes = [
-        ('longdouble', 'interp_boxes.W_LongDoubleBox'),
-        ('longfloat', 'interp_boxes.W_LongDoubleBox'),
-        ('clongdouble', 'interp_boxes.W_CLongDoubleBox'),
-        ('clongfloat', 'interp_boxes.W_CLongDoubleBox'),
-      ]
-    if long_double_size == 16:
-        long_double_dtypes += [
-            ('float128', 'interp_boxes.W_Float128Box'),
-            ('complex256', 'interp_boxes.W_Complex256Box'),
-            ]
-    elif long_double_size == 12:
-        long_double_dtypes += [
-            ('float96', 'interp_boxes.W_Float96Box'),
-            ('complex192', 'interp_boxes.W_Complex192Box'),
-            ]
-    for dt, box in long_double_dtypes:
-        Module.interpleveldefs[dt] = box
+    submodules = {
+        'multiarray': MultiArrayModule,
+        'numerictypes': NumericTypesModule,
+        'umath': UMathModule,
+    }
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
@@ -10,9 +10,9 @@
         stop = start
         start = 0
     if dtype is None:
-        test = _numpypy.array([start, stop, step, 0])
+        test = _numpypy.multiarray.array([start, stop, step, 0])
         dtype = test.dtype
-    arr = _numpypy.zeros(int(math.ceil((stop - start) / step)), dtype=dtype)
+    arr = _numpypy.multiarray.zeros(int(math.ceil((stop - start) / step)), dtype=dtype)
     i = start
     for j in range(arr.size):
         arr[j] = i
diff --git a/pypy/module/micronumpy/interp_arrayops.py b/pypy/module/micronumpy/interp_arrayops.py
--- a/pypy/module/micronumpy/interp_arrayops.py
+++ b/pypy/module/micronumpy/interp_arrayops.py
@@ -135,7 +135,7 @@
     return res
 
 @unwrap_spec(repeats=int)
-def repeat(space, w_arr, repeats, w_axis=None):
+def repeat(space, w_arr, repeats, w_axis):
     arr = convert_to_array(space, w_arr)
     if space.is_none(w_axis):
         arr = arr.descr_flatten(space)
@@ -161,14 +161,21 @@
 def count_nonzero(space, w_obj):
     return space.wrap(loop.count_all_true(convert_to_array(space, w_obj)))
 
-def choose(space, arr, w_choices, out, mode):
+ at unwrap_spec(mode=str)
+def choose(space, w_arr, w_choices, w_out, mode):
+    arr = convert_to_array(space, w_arr)
     choices = [convert_to_array(space, w_item) for w_item
                in space.listview(w_choices)]
     if not choices:
         raise OperationError(space.w_ValueError,
                              space.wrap("choices list cannot be empty"))
-    shape = shape_agreement_multiple(space, choices + [out])
-    out = interp_dtype.dtype_agreement(space, choices, shape, out)
+    if space.is_none(w_out):
+        w_out = None
+    elif not isinstance(w_out, W_NDimArray):
+        raise OperationError(space.w_TypeError, space.wrap(
+            "return arrays must be of ArrayType"))
+    shape = shape_agreement_multiple(space, choices + [w_out])
+    out = interp_dtype.dtype_agreement(space, choices, shape, w_out)
     dtype = out.get_dtype()
     if mode not in MODES:
         raise OperationError(space.w_ValueError,
diff --git a/pypy/module/micronumpy/interp_numarray.py b/pypy/module/micronumpy/interp_numarray.py
--- a/pypy/module/micronumpy/interp_numarray.py
+++ b/pypy/module/micronumpy/interp_numarray.py
@@ -14,7 +14,7 @@
 from pypy.module.micronumpy.appbridge import get_appbridge_cache
 from pypy.module.micronumpy import loop
 from pypy.module.micronumpy.dot import match_dot_shapes
-from pypy.module.micronumpy.interp_arrayops import repeat
+from pypy.module.micronumpy.interp_arrayops import repeat, choose
 from rpython.tool.sourcetools import func_with_new_name
 from rpython.rlib import jit
 from rpython.rlib.rstring import StringBuilder
@@ -452,13 +452,8 @@
             return res
 
     @unwrap_spec(mode=str)
-    def descr_choose(self, space, w_choices, mode='raise', w_out=None):
-        if space.is_none(w_out):
-            w_out = None
-        elif not isinstance(w_out, W_NDimArray):
-            raise OperationError(space.w_TypeError, space.wrap(
-                "return arrays must be of ArrayType"))
-        return interp_arrayops.choose(space, self, w_choices, w_out, mode)
+    def descr_choose(self, space, w_choices, w_out=None, mode='raise'):
+        return choose(space, self, w_choices, w_out, mode)
 
     def descr_clip(self, space, w_min, w_max, w_out=None):
         if space.is_none(w_out):
diff --git a/pypy/module/micronumpy/test/test_arrayops.py b/pypy/module/micronumpy/test/test_arrayops.py
--- a/pypy/module/micronumpy/test/test_arrayops.py
+++ b/pypy/module/micronumpy/test/test_arrayops.py
@@ -3,26 +3,26 @@
 
 class AppTestNumSupport(BaseNumpyAppTest):
     def test_where(self):
-        from _numpypy import where, ones, zeros, array
+        from numpypy import where, ones, zeros, array
         a = [1, 2, 3, 0, -3]
         a = where(array(a) > 0, ones(5), zeros(5))
         assert (a == [1, 1, 1, 0, 0]).all()
 
     def test_where_differing_dtypes(self):
-        from _numpypy import array, ones, zeros, where
+        from numpypy import array, ones, zeros, where
         a = [1, 2, 3, 0, -3]
         a = where(array(a) > 0, ones(5, dtype=int), zeros(5, dtype=float))
         assert (a == [1, 1, 1, 0, 0]).all()
 
     def test_where_broadcast(self):
-        from _numpypy import array, where
+        from numpypy import array, where
         a = where(array([[1, 2, 3], [4, 5, 6]]) > 3, [1, 1, 1], 2)
         assert (a == [[2, 2, 2], [1, 1, 1]]).all()
         a = where(True, [1, 1, 1], 2)
         assert (a == [1, 1, 1]).all()
 
     def test_where_errors(self):
-        from _numpypy import where, array
+        from numpypy import where, array
         raises(ValueError, "where([1, 2, 3], [3, 4, 5])")
         raises(ValueError, "where([1, 2, 3], [3, 4, 5], [6, 7])")
         assert where(True, 1, 2) == array(1)
@@ -35,7 +35,7 @@
     #    xxx
 
     def test_where_invalidates(self):
-        from _numpypy import where, ones, zeros, array
+        from numpypy import where, ones, zeros, array
         a = array([1, 2, 3, 0, -3])
         b = where(a > 0, ones(5), zeros(5))
         a[0] = 0
@@ -43,7 +43,7 @@
 
 
     def test_dot(self):
-        from _numpypy import array, dot, arange
+        from numpypy import array, dot, arange
         a = array(range(5))
         assert dot(a, a) == 30.0
 
@@ -74,7 +74,7 @@
         assert (dot([[1,2],[3,4]],[5,6]) == [17, 39]).all()
 
     def test_dot_constant(self):
-        from _numpypy import array, dot
+        from numpypy import array, dot
         a = array(range(5))
         b = a.dot(2.5)
         for i in xrange(5):
@@ -85,19 +85,21 @@
         assert c == 12.0
 
     def test_choose_basic(self):
-        from _numpypy import array
+        from numpypy import array, choose
         a, b, c = array([1, 2, 3]), array([4, 5, 6]), array([7, 8, 9])
         r = array([2, 1, 0]).choose([a, b, c])
         assert (r == [7, 5, 3]).all()
+        r = choose(array([2, 1, 0]), [a, b, c])
+        assert (r == [7, 5, 3]).all()
 
     def test_choose_broadcast(self):
-        from _numpypy import array
+        from numpypy import array
         a, b, c = array([1, 2, 3]), [4, 5, 6], 13
         r = array([2, 1, 0]).choose([a, b, c])
         assert (r == [13, 5, 3]).all()
 
     def test_choose_out(self):
-        from _numpypy import array
+        from numpypy import array
         a, b, c = array([1, 2, 3]), [4, 5, 6], 13
         r = array([2, 1, 0]).choose([a, b, c], out=None)
         assert (r == [13, 5, 3]).all()
@@ -107,10 +109,10 @@
         assert (a == [13, 5, 3]).all()
 
     def test_choose_modes(self):
-        from _numpypy import array
+        from numpypy import array
         a, b, c = array([1, 2, 3]), [4, 5, 6], 13
         raises(ValueError, "array([3, 1, 0]).choose([a, b, c])")
-        raises(ValueError, "array([3, 1, 0]).choose([a, b, c], 'raises')")
+        raises(ValueError, "array([3, 1, 0]).choose([a, b, c], mode='raises')")
         raises(ValueError, "array([3, 1, 0]).choose([])")
         raises(ValueError, "array([-1, -2, -3]).choose([a, b, c])")
         r = array([4, 1, 0]).choose([a, b, c], mode='clip')
@@ -119,13 +121,13 @@
         assert (r == [4, 5, 3]).all()
 
     def test_choose_dtype(self):
-        from _numpypy import array
+        from numpypy import array
         a, b, c = array([1.2, 2, 3]), [4, 5, 6], 13
         r = array([2, 1, 0]).choose([a, b, c])
         assert r.dtype == float
 
     def test_choose_dtype_out(self):
-        from _numpypy import array
+        from numpypy import array
         a, b, c = array([1, 2, 3]), [4, 5, 6], 13
         x = array([0, 0, 0], dtype='i2')
         r = array([2, 1, 0]).choose([a, b, c], out=x)
diff --git a/pypy/module/micronumpy/test/test_base.py b/pypy/module/micronumpy/test/test_base.py
--- a/pypy/module/micronumpy/test/test_base.py
+++ b/pypy/module/micronumpy/test/test_base.py
@@ -15,7 +15,6 @@
             if '__pypy__' not in sys.builtin_module_names:
                 import numpy
                 sys.modules['numpypy'] = numpy
-                sys.modules['_numpypy'] = numpy
         cls.w_non_native_prefix = cls.space.wrap(nonnative_byteorder_prefix)
         cls.w_native_prefix = cls.space.wrap(byteorder_prefix)
 
diff --git a/pypy/module/micronumpy/test/test_complex.py b/pypy/module/micronumpy/test/test_complex.py
--- a/pypy/module/micronumpy/test/test_complex.py
+++ b/pypy/module/micronumpy/test/test_complex.py
@@ -132,13 +132,13 @@
             cls.w_c_pow = cls.space.wrap(interp2app(cls_c_pow))
 
     def test_fabs(self):
-        from _numpypy import fabs, complex128
+        from numpypy import fabs, complex128
 
         a = complex128(complex(-5., 5.))
         raises(TypeError, fabs, a)
 
     def test_fmax(self):
-        from _numpypy import fmax, array
+        from numpypy import fmax, array
         nnan, nan, inf, ninf = float('-nan'), float('nan'), float('inf'), float('-inf')
         a = array((complex(ninf, 10), complex(10, ninf), 
                    complex( inf, 10), complex(10,  inf),
@@ -165,7 +165,7 @@
         assert (fmax(a, b) == res).all()
 
     def test_fmin(self):
-        from _numpypy import fmin, array
+        from numpypy import fmin, array
         nnan, nan, inf, ninf = float('-nan'), float('nan'), float('inf'), float('-inf')
         a = array((complex(ninf, 10), complex(10, ninf), 
                    complex( inf, 10), complex(10,  inf),
@@ -192,14 +192,14 @@
         assert (fmin(a, b) == res).all()
 
     def test_signbit(self):
-        from _numpypy import signbit
+        from numpypy import signbit
         raises(TypeError, signbit, complex(1,1))
 
     def test_reciprocal(self):
-        from _numpypy import array, reciprocal, complex64, complex128
+        from numpypy import array, reciprocal, complex64, complex128
         c_and_relerr = [(complex64, 2e-7), (complex128, 2e-15)]
         try:
-            from _numpypy import clongdouble
+            from numpypy import clongdouble
             c_and_relerr.append((clongdouble, 2e-30))
         except:
             pass # no longdouble yet
@@ -224,23 +224,23 @@
                 assert (a[0].imag - e.imag) < rel_err
 
     def test_floorceiltrunc(self):
-        from _numpypy import array, floor, ceil, trunc
+        from numpypy import array, floor, ceil, trunc
         a = array([ complex(-1.4, -1.4), complex(-1.5, -1.5)]) 
         raises(TypeError, floor, a)
         raises(TypeError, ceil, a)
         raises(TypeError, trunc, a)
 
     def test_copysign(self):
-        from _numpypy import copysign, complex128
+        from numpypy import copysign, complex128
         a = complex128(complex(-5., 5.))
         b = complex128(complex(0., 0.))
         raises(TypeError, copysign, a, b)
 
     def test_exp2(self):
-        from _numpypy import array, exp2, complex128, complex64
+        from numpypy import array, exp2, complex128, complex64
         c_and_relerr = [(complex64, 2e-7), (complex128, 2e-15)]
         try:
-            from _numpypy import clongdouble
+            from numpypy import clongdouble
             c_and_relerr.append((clongdouble, 2e-30))
         except:
             pass # no longdouble yet
@@ -279,7 +279,7 @@
 
     def test_expm1(self):
         import math, cmath
-        from _numpypy import array, expm1, complex128, complex64
+        from numpypy import array, expm1, complex128, complex64
         inf = float('inf')
         ninf = -float('inf')
         nan = float('nan')
@@ -318,7 +318,7 @@
                 self.rAlmostEqual(t1, t2, rel_err=rel_err, msg=msg)
 
     def test_not_complex(self):
-        from _numpypy import (radians, deg2rad, degrees, rad2deg,
+        from numpypy import (radians, deg2rad, degrees, rad2deg,
                   isneginf, isposinf, logaddexp, logaddexp2, fmod,
                   arctan2)
         raises(TypeError, radians, complex(90,90))
@@ -333,7 +333,7 @@
         raises (TypeError, fmod, complex(90,90), 3) 
 
     def test_isnan_isinf(self):
-        from _numpypy import isnan, isinf, array
+        from numpypy import isnan, isinf, array
         assert (isnan(array([0.2+2j, complex(float('inf'),0), 
                 complex(0,float('inf')), complex(0,float('nan')),
                 complex(float('nan'), 0)], dtype=complex)) == \
@@ -346,7 +346,7 @@
 
 
     def test_square(self):
-        from _numpypy import square
+        from numpypy import square
         assert square(complex(3, 4)) == complex(3,4) * complex(3, 4)
 
     def test_power_complex(self):
@@ -355,7 +355,7 @@
         nan = float('nan')
         cmpl = complex
         from math import copysign
-        from _numpypy import power, array, complex128, complex64
+        from numpypy import power, array, complex128, complex64
         # note: in some settings (namely a x86-32 build without the JIT),
         # gcc optimizes the code in rlib.rcomplex.c_pow() to not truncate
         # the 10-byte values down to 8-byte values.  It ends up with more
@@ -392,7 +392,7 @@
                     self.rAlmostEqual(t1, t2, rel_err=rel_err, msg=msg)
 
     def test_conjugate(self):
-        from _numpypy import conj, conjugate, complex128, complex64
+        from numpypy import conj, conjugate, complex128, complex64
         import numpypy as np
 
         c0 = complex128(complex(2.5, 0))
@@ -416,7 +416,7 @@
     def test_logn(self):
         import math, cmath
         # log and log10 are tested in math (1:1 from rcomplex)
-        from _numpypy import log2, array, complex128, complex64, log1p
+        from numpypy import log2, array, complex128, complex64, log1p
         inf = float('inf')
         ninf = -float('inf')
         nan = float('nan')
@@ -473,7 +473,7 @@
                 self.rAlmostEqual(t1, t2, rel_err=rel_err, msg=msg)
 
     def test_logical_ops(self):
-        from _numpypy import logical_and, logical_or, logical_xor, logical_not
+        from numpypy import logical_and, logical_or, logical_xor, logical_not
 
         c1 = complex(1, 1)
         c3 = complex(3, 0)
@@ -487,7 +487,7 @@
         assert (logical_not([c1, c0]) == [False, True]).all()
 
     def test_minimum(self):
-        from _numpypy import array, minimum
+        from numpypy import array, minimum
 
         a = array([-5.0+5j, -5.0-5j, -0.0-10j, 1.0+10j])
         b = array([ 3.0+10.0j, 3.0, -2.0+2.0j, -3.0+4.0j])
@@ -496,7 +496,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+5j, -5.0-5j, -0.0-10j, 1.0+10j])
         b = array([ 3.0+10.0j, 3.0, -2.0+2.0j, -3.0+4.0j])
@@ -505,14 +505,14 @@
             assert c[i] == max(a[i], b[i])
 
     def test_basic(self):
-        from _numpypy import (complex128, complex64, add, array, dtype,
+        from numpypy import (complex128, complex64, add, array, dtype,
             subtract as sub, multiply, divide, negative, absolute as abs,
             floor_divide, real, imag, sign)
-        from _numpypy import (equal, not_equal, greater, greater_equal, less,
+        from numpypy import (equal, not_equal, greater, greater_equal, less,
                 less_equal, isnan)
         complex_dtypes = [complex64, complex128]
         try:
-            from _numpypy import clongfloat
+            from numpypy import clongfloat
             complex_dtypes.append(clongfloat)
         except:
             pass
@@ -588,15 +588,15 @@
             inf_c = complex_(complex(float('inf'), 0.))
             assert repr(abs(inf_c)) == 'inf'
             assert repr(abs(complex(float('nan'), float('nan')))) == 'nan'
-            # numpy actually raises an AttributeError, 
-            # but _numpypy raises a TypeError
+            # numpy actually raises an AttributeError,
+            # but numpypy raises a TypeError
             raises((TypeError, AttributeError), 'c2.real = 10.')
             raises((TypeError, AttributeError), 'c2.imag = 10.')
             assert(real(c2) == 3.0)
             assert(imag(c2) == 4.0)
 
     def test_conj(self):
-        from _numpypy import array
+        from numpypy import array
 
         a = array([1 + 2j, 1 - 2j])
         assert (a.conj() == [1 - 2j, 1 + 2j]).all()
@@ -605,7 +605,7 @@
         if self.isWindows:
             skip('windows does not support c99 complex')
         import sys
-        import _numpypy as np
+        import numpypy as np
         rAlmostEqual = self.rAlmostEqual
 
         for complex_, abs_err, testcases in (\
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
@@ -17,7 +17,7 @@
     
 class AppTestDtypes(BaseAppTestDtypes):
     def test_dtype(self):
-        from _numpypy import dtype
+        from numpypy import dtype
 
         d = dtype('?')
         assert d.num == 0
@@ -36,7 +36,7 @@
         raises(KeyError, 'dtype(int)["asdasd"]')
 
     def test_dtype_eq(self):
-        from _numpypy import dtype
+        from numpypy import dtype
 
         assert dtype("int8") == "int8"
         assert "int8" == dtype("int8")
@@ -44,7 +44,7 @@
         assert dtype(bool) == bool
 
     def test_dtype_with_types(self):
-        from _numpypy import dtype
+        from numpypy import dtype
 
         assert dtype(bool).num == 0
         if self.ptr_size == 4:
@@ -66,13 +66,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 '.dtype' in repr(dtype)
         d = dtype('?')
@@ -80,7 +80,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_
@@ -88,7 +88,7 @@
             assert a[i] is True_
 
     def test_copy_array_with_dtype(self):
-        from _numpypy import array, False_, longlong
+        from numpypy import array, longlong, False_
 
         a = array([0, 1, 2, 3], dtype=long)
         # int on 64-bit, long in 32-bit
@@ -102,35 +102,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, longlong
+        from numpypy import zeros, longlong
         a = zeros(10, dtype=long)
         for i in range(10):
             assert isinstance(a[i], longlong)
             assert a[1] == 0
 
     def test_ones_long(self):
-        from _numpypy import ones, longlong
+        from numpypy import ones, longlong
         a = ones(10, dtype=long)
         for i in range(10):
             assert isinstance(a[i], longlong)
             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
@@ -142,7 +142,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', 
             'e'
@@ -152,7 +152,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'),
@@ -176,7 +176,7 @@
             assert (d1, d2) == (d1, d2) and d3 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
@@ -185,7 +185,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
@@ -194,7 +194,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
@@ -203,49 +203,49 @@
             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,), {})
 
     def test_can_subclass(self):
-        import _numpypy
-        class xyz(_numpypy.void):
+        import numpypy
+        class xyz(numpypy.void):
             pass
         assert True
 
     def test_aliases(self):
-        from _numpypy import dtype
+        from numpypy import dtype
 
         assert dtype("float") is dtype(float)
 
     def test_index_int8(self):
-        from _numpypy import array, int8
+        from numpypy import array, int8
 
         a = array(range(10), dtype=int8)
         b = array([0] * 10, dtype=int8)
         for idx in b: a[idx] += 1
 
     def test_index_int16(self):
-        from _numpypy import array, int16
+        from numpypy import array, int16
 
         a = array(range(10), dtype=int16)
         b = array([0] * 10, dtype=int16)
         for idx in b: a[idx] += 1
 
     def test_index_int32(self):
-        from _numpypy import array, int32
+        from numpypy import array, int32
 
         a = array(range(10), dtype=int32)
         b = array([0] * 10, dtype=int32)
         for idx in b: a[idx] += 1
 
     def test_index_int64(self):
-        from _numpypy import array, int64
+        from numpypy import array, int64
 
         a = array(range(10), dtype=int64)
         b = array([0] * 10, dtype=int64)
@@ -253,7 +253,7 @@
             a[idx] += 1
 
     def test_hash(self):
-        import _numpypy as numpy
+        import numpypy as numpy
         for tp, value in [
             (numpy.int8, 4),
             (numpy.int16, 5),
@@ -268,7 +268,7 @@
 
 class AppTestTypes(BaseAppTestDtypes):
     def test_abstract_types(self):
-        import _numpypy as numpy
+        import numpypy as numpy
 
         raises(TypeError, numpy.generic, 0)
         raises(TypeError, numpy.number, 0)
@@ -308,16 +308,16 @@
         #assert a.dtype is numpy.dtype('|V4')
 
     def test_new(self):
-        import _numpypy as np
+        import numpypy as np
         assert np.int_(4) == 4
         assert np.float_(3.4) == 3.4
 
     def test_pow(self):
-        from _numpypy import int_
+        from numpypy import int_
         assert int_(4) ** 2 == 16
 
     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_
@@ -332,7 +332,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, 
@@ -356,7 +356,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, 
@@ -381,7 +381,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
@@ -391,7 +391,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
@@ -400,7 +400,7 @@
 
     def test_int32(self):
         import sys
-        import _numpypy as numpy
+        import numpypy as numpy
 
         x = numpy.int32(23)
         assert x == 23
@@ -416,7 +416,7 @@
 
     def test_uint32(self):
         import sys
-        import _numpypy as numpy
+        import numpypy as numpy
 
         assert numpy.uint32(10) == 10
 
@@ -427,7 +427,7 @@
             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, 
@@ -436,7 +436,7 @@
 
     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, 
@@ -458,7 +458,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, 
@@ -475,7 +475,7 @@
         raises(OverflowError, numpy.uint64(18446744073709551616))
 
     def test_float16(self):
-        import _numpypy as numpy
+        import numpypy as numpy
         assert numpy.float16.mro() == [numpy.float16, numpy.floating, 
                                        numpy.inexact, numpy.number, 
                                        numpy.generic, object]
@@ -486,7 +486,7 @@
 
 
     def test_float32(self):
-        import _numpypy as numpy
+        import numpypy as numpy
 
         assert numpy.float32.mro() == [numpy.float32, numpy.floating, 
                                        numpy.inexact, numpy.number, 
@@ -497,7 +497,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, 
@@ -514,20 +514,20 @@
         raises(ValueError, numpy.float64, '23.2df')
 
     def test_float_None(self):
-        import _numpypy as numpy
+        import numpypy as numpy
         from math import isnan
         assert isnan(numpy.float32(None))
         assert isnan(numpy.float64(None))
 
     def test_complex_floating(self):
-        import _numpypy as numpy
+        import numpypy as numpy
 
         assert numpy.complexfloating.__mro__ == (numpy.complexfloating,
             numpy.inexact, numpy.number, numpy.generic, object)
 
     def test_complex_format(self):
         import sys
-        import _numpypy as numpy
+        import numpypy as numpy
 
         for complex_ in (numpy.complex128, numpy.complex64,):
             for real, imag, should in [
@@ -567,7 +567,7 @@
             assert "{:g}".format(numpy.complex_(0.5+1.5j)) == '{:g}'.format(0.5+1.5j)
 
     def test_complex(self):
-        import _numpypy as numpy
+        import numpypy as numpy
 
         assert numpy.complex_ is numpy.complex128
         assert numpy.complex64.__mro__ == (numpy.complex64,
@@ -585,7 +585,7 @@
         assert d.char == 'F'
 
     def test_subclass_type(self):
-        import _numpypy as numpy
+        import numpypy as numpy
 
         class X(numpy.float64):
             def m(self):
@@ -596,12 +596,12 @@
         assert b.m() == 12
 
     def test_long_as_index(self):
-        from _numpypy import int_, float64
+        from numpypy import int_, float64
         assert (1, 2, 3)[int_(1)] == 2
         raises(TypeError, lambda: (1, 2, 3)[float64(1)])
 
     def test_int(self):
-        from _numpypy import int32, int64, int_
+        from numpypy import int32, int64, int_
         import sys
         assert issubclass(int_, int)
         if sys.maxint == (1<<31) - 1:
@@ -612,7 +612,7 @@
             assert int_ is int64
 
     def test_various_types(self):
-        import _numpypy as numpy
+        import numpypy as numpy
 
         assert numpy.int16 is numpy.short
         assert numpy.int8 is numpy.byte
@@ -625,7 +625,7 @@
             assert numpy.uintp is numpy.uint64
 
     def test_mro(self):
-        import _numpypy as numpy
+        import numpypy as numpy
 
         assert numpy.int16.__mro__ == (numpy.int16, numpy.signedinteger,
                                        numpy.integer, numpy.number,
@@ -634,7 +634,7 @@
 
     def test_operators(self):
         from operator import truediv
-        from _numpypy import float64, int_, True_, False_
+        from numpypy import float64, int_, True_, False_
         assert 5 / int_(2) == int_(2)
         assert truediv(int_(3), int_(2)) == float64(1.5)
         assert truediv(3, int_(2)) == float64(1.5)
@@ -659,7 +659,7 @@
         raises(TypeError, lambda: float64(3) & 1)
 
     def test_alternate_constructs(self):
-        from _numpypy import dtype
+        from numpypy import dtype
         nnp = self.non_native_prefix
         byteorder = self.native_prefix
         assert dtype('i8') == dtype(byteorder + 'i8') == dtype('=i8') # XXX should be equal == dtype(long)
@@ -669,23 +669,23 @@
         assert dtype(byteorder + 'i8').byteorder == '='
 
     def test_intp(self):
-        from _numpypy import dtype
+        from numpypy import dtype
         assert dtype('p') == dtype('intp')
         assert dtype('P') == dtype('uintp')
 
     def test_alignment(self):
-        from _numpypy import dtype
+        from numpypy import dtype
         assert dtype('i4').alignment == 4
 
 class AppTestStrUnicodeDtypes(BaseNumpyAppTest):
     def test_str_unicode(self):
-        from _numpypy import str_, unicode_, character, flexible, generic
+        from numpypy import str_, unicode_, character, flexible, generic
 
         assert str_.mro() == [str_, str, basestring, character, flexible, generic, object]
         assert unicode_.mro() == [unicode_, unicode, basestring, character, flexible, generic, object]
 
     def test_str_dtype(self):
-        from _numpypy import dtype, str_
+        from numpypy import dtype, str_
 
         raises(TypeError, "dtype('Sx')")
         d = dtype('S8')
@@ -697,7 +697,7 @@
         assert d.num == 18
 
     def test_unicode_dtype(self):
-        from _numpypy import dtype, unicode_
+        from numpypy import dtype, unicode_
 
         raises(TypeError, "dtype('Ux')")
         d = dtype('U8')
@@ -709,16 +709,16 @@
         assert d.num == 19
 
     def test_string_boxes(self):
-        from _numpypy import str_
+        from numpypy import str_
         assert isinstance(str_(3), str_)
 
     def test_unicode_boxes(self):
-        from _numpypy import unicode_
+        from numpypy import unicode_
         assert isinstance(unicode_(3), unicode)
 
 class AppTestRecordDtypes(BaseNumpyAppTest):
     def test_create(self):
-        from _numpypy import dtype, void
+        from numpypy import dtype, void
 
         raises(ValueError, "dtype([('x', int), ('x', float)])")
         d = dtype([("x", "int32"), ("y", "int32"), ("z", "int32"), ("value", float)])
@@ -737,7 +737,7 @@
 
     def test_create_from_dict(self):
         skip("not yet")
-        from _numpypy import dtype
+        from numpypy import dtype
         d = dtype({'names': ['a', 'b', 'c'],
                    })
 
@@ -761,7 +761,7 @@
             cls.w_check_non_native = cls.space.wrap(interp2app(check_non_native))
 
     def test_non_native(self):
-        from _numpypy import array
+        from numpypy import array
         a = array([1, 2, 3], dtype=self.non_native_prefix + 'i2')
         assert a[0] == 1
         assert (a + a)[1] == 4
@@ -783,7 +783,8 @@
         BaseNumpyAppTest.setup_class.im_func(cls)
 
     def test_typeinfo(self):
-        from _numpypy import typeinfo, void, number, int64, bool_
+        from numpypy import void, number, int64, bool_
+        from numpypy.core.multiarray import typeinfo
         assert typeinfo['Number'] == number
         assert typeinfo['LONGLONG'] == ('q', 9, 64, 8, 9223372036854775807L, -9223372036854775808L, int64)
         assert typeinfo['VOID'] == ('V', 20, 0, 1, void)
@@ -799,11 +800,11 @@
         BaseNumpyAppTest.setup_class.im_func(cls)
 
     def test_nolongfloat(self):
-        import _numpypy
-        from _numpypy import dtype
-        assert not getattr(_numpypy, 'longdouble', False)
-        assert not getattr(_numpypy, 'float128', False)
-        assert not getattr(_numpypy, 'float96', False)
+        import numpypy
+        from numpypy import dtype
+        assert not getattr(numpypy, 'longdouble', False)
+        assert not getattr(numpypy, 'float128', False)
+        assert not getattr(numpypy, 'float96', False)
         raises(TypeError, dtype, 'longdouble')
         raises(TypeError, dtype, 'clongdouble')
         raises(TypeError, dtype, 'longfloat')
@@ -820,7 +821,7 @@
         BaseNumpyAppTest.setup_class.im_func(cls)
 
     def test_longfloat(self):
-        import _numpypy as numpy
+        import numpypy as numpy
         # it can be float96 or float128
         if numpy.longfloat != numpy.float64:
             assert numpy.longfloat.mro()[1:] == [numpy.floating,
@@ -833,33 +834,33 @@
         raises(ValueError, numpy.longfloat, '23.2df')
 
     def test_dtype_aliases(self):
-        from _numpypy import dtype
+        from numpypy import dtype
         assert dtype('longfloat').num in (12, 13)
         assert dtype('longdouble').num in (12, 13)
         assert dtype('clongfloat').num in (15, 16)
         assert dtype('clongdouble').num in (15, 16)
 
     def test_bool_binop_types(self):
-        from _numpypy import array, dtype
+        from numpypy import array, dtype
         types = ['g', 'G']
         a = array([True], '?')
         for t in types:
             assert (a + array([0], t)).dtype is dtype(t)
 
     def test_hash(self):
-        import _numpypy as numpy
+        import numpypy as numpy
         for tp, value in [
             (numpy.longdouble, 4.32),
         ]:
             assert hash(tp(value)) == hash(value)
 
     def test_float_None(self):
-        import _numpypy as numpy
+        import numpypy as numpy
         from math import isnan
         assert isnan(numpy.longdouble(None))
 
     def test_non_native(self):
-        from _numpypy import array
+        from numpypy import array
         a = array([1, 2, 3], dtype=self.non_native_prefix + 'g') # longdouble
         assert a[0] == 1
         assert (a + a)[1] == 4
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
@@ -245,7 +245,7 @@
         return CustomIntObject(value)
 
     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
@@ -262,24 +262,24 @@
         assert a.shape == ()
 
     def test_ndmin(self):
-        from _numpypy import array
+        from numpypy import array
 
         arr = array([[[1]]], ndmin=1)
         assert arr.shape == (1, 1, 1)
 
     def test_noop_ndmin(self):
-        from _numpypy import array
+        from numpypy import array
 
         arr = array([1], ndmin=3)
         assert arr.shape == (1, 1, 1)
 
     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])
@@ -288,12 +288,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, AttributeError), '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
@@ -303,7 +303,7 @@
         assert zeros(()).shape == ()
 
     def test_size(self):
-        from _numpypy import array,arange,cos
+        from numpypy import array,arange,cos
         assert array(3).size == 1
         a = array([1, 2, 3])
         assert a.size == 3
@@ -316,13 +316,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
@@ -331,7 +331,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):
@@ -357,12 +357,12 @@
         assert b[0] == a[0]
 
     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
@@ -371,14 +371,14 @@
         raises(IndexError, "a[-6]")
 
     def test_getitem_float(self):
-        from _numpypy import array
+        from numpypy import array
         a = array([1, 2, 3, 4])
         assert a[1.2] == 2
         assert a[1.6] == 2
         assert a[-1.2] == 4
 
     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):
@@ -388,20 +388,20 @@
             assert a[i] == b[i]
 
     def test_getitem_nd(self):
-        from _numpypy import arange
+        from numpypy import arange
         a = arange(15).reshape(3, 5)
         assert a[1, 3] == 8
         assert a.T[1, 2] == 11
 
     def test_getitem_obj_index(self):
-        from _numpypy import arange
+        from numpypy import arange
 
         a = arange(10)
 
         assert a[self.CustomIndexObject(1)] == 1
 
     def test_getitem_obj_prefer_index_to_int(self):
-        from _numpypy import arange
+        from numpypy import arange
 
         a = arange(10)
 
@@ -409,14 +409,14 @@
         assert a[self.CustomIndexIntObject(0, 1)] == 0
 
     def test_getitem_obj_int(self):
-        from _numpypy import arange
+        from numpypy import arange
 
         a = arange(10)
 
         assert a[self.CustomIntObject(1)] == 1
 
     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
@@ -424,7 +424,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):
@@ -435,7 +435,7 @@
             assert a[i] == i
 
     def test_setitem_obj_index(self):
-        from _numpypy import arange
+        from numpypy import arange
 
         a = arange(10)
 
@@ -443,7 +443,7 @@
         assert a[1] == 100
 
     def test_setitem_obj_prefer_index_to_int(self):
-        from _numpypy import arange
+        from numpypy import arange
 
         a = arange(10)
 
@@ -451,7 +451,7 @@
         assert a[0] == 100
 
     def test_setitem_obj_int(self):
-        from _numpypy import arange
+        from numpypy import arange
 
         a = arange(10)
 
@@ -471,13 +471,13 @@
         # numpy will swallow errors in __int__ and __index__ and
         # just raise IndexError.
 
-        from _numpypy import arange
+        from numpypy import arange
         a = arange(10)
         raises(IndexError, "a[ErrorIndex()] == 0")
         raises(IndexError, "a[ErrorInt()] == 0")
 
     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
@@ -488,7 +488,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.
@@ -507,7 +507,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
@@ -515,7 +515,7 @@
         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.
@@ -523,7 +523,7 @@
 
     def test_newaxis(self):
         import math
-        from _numpypy import array, cos, zeros
+        from numpypy import array, cos, zeros
         from numpypy.core.numeric import newaxis
         a = array(range(5))
         b = array([range(5)])
@@ -537,7 +537,7 @@
         assert ((cos(a)[:,newaxis] * cos(b).T) == expected).all()
 
     def test_newaxis_slice(self):
-        from _numpypy import array
+        from numpypy import array
         from numpypy.core.numeric import newaxis
 
         a = array(range(5))
@@ -550,7 +550,7 @@
         assert (a[newaxis,1:] == c).all()
 
     def test_newaxis_assign(self):
-        from _numpypy import array
+        from numpypy import array
         from numpypy.core.numeric import newaxis
 
         a = array(range(5))
@@ -558,7 +558,7 @@
         assert a[1] == 2
 
     def test_newaxis_virtual(self):
-        from _numpypy import array
+        from numpypy import array
         from numpypy.core.numeric import newaxis
 
         a = array(range(5))
@@ -567,7 +567,7 @@
         assert (b == c).all()
 
     def test_newaxis_then_slice(self):
-        from _numpypy import array
+        from numpypy import array
         from numpypy.core.numeric import newaxis
         a = array(range(5))
         b = a[newaxis]
@@ -575,14 +575,14 @@
         assert (b[0,1:] == a[1:]).all()
 
     def test_slice_then_newaxis(self):
-        from _numpypy import array
+        from numpypy import array
         from numpypy.core.numeric import newaxis
         a = array(range(5))
         b = a[2:]
         assert (b[newaxis] == [[2, 3, 4]]).all()
 
     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")
@@ -591,13 +591,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
@@ -607,7 +607,7 @@
         assert array([]).shape == (0,)
 
     def test_set_shape(self):
-        from _numpypy import array, zeros
+        from numpypy import array, zeros
         a = array([])
         raises(ValueError, "a.shape = []")
         a = array(range(12))
@@ -630,7 +630,7 @@
         raises(AttributeError, 'a.shape = 6')
 
     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"
@@ -646,7 +646,7 @@
         assert a.reshape((0,)).shape == (0,)
 
     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)
@@ -682,7 +682,7 @@
         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)
@@ -695,19 +695,19 @@
         raises(ValueError, "a.reshape(3)")
 
     def test_strides(self):
-        from _numpypy import array
+        from numpypy import array
         a = array([[1.0, 2.0],
                    [3.0, 4.0]])
         assert a.strides == (16, 8)
         assert a[1:].strides == (16, 8)
 
     def test_strides_scalar(self):
-        from _numpypy import array
+        from numpypy import array
         a = array(42)
         assert a.strides == ()
 
     def test_add(self):
-        from _numpypy import array
+        from numpypy import array
         a = array(range(5))
         b = a + a
         for i in range(5):
@@ -720,7 +720,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
@@ -728,14 +728,14 @@
             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
@@ -743,7 +743,7 @@
         assert (r == [2, 4]).all()
 
     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
@@ -752,14 +752,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
@@ -767,35 +767,35 @@
             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
         assert b.dtype is a.dtype
 
-        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):
@@ -803,7 +803,7 @@
 
     def test_div(self):
         from math import isnan
-        from _numpypy import array, dtype
+        from numpypy import array, dtype
 
         a = array(range(1, 6))
         b = a / a
@@ -835,7 +835,7 @@
         assert c[2] == float('-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)


More information about the pypy-commit mailing list