Commits

Philip Jenvey committed f421876 Merge

merge default

  • Participants
  • Parent commits f9424c2, 5c24412
  • Branches py3k

Comments (0)

Files changed (80)

 ^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$

File lib_pypy/numpypy/core/__init__.py

-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__

File lib_pypy/numpypy/core/_methods.py

 # 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,

File lib_pypy/numpypy/core/arrayprint.py

 # 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
 
 
             #else:
             format_function = formatdict['int']
         elif issubclass(dtypeobj, _nt.floating):
-            if issubclass(dtypeobj, _nt.longfloat):
+            if hasattr(_nt, 'longfloat') and issubclass(dtypeobj, _nt.longfloat):
                 format_function = formatdict['longfloat']
             else:
                 format_function = formatdict['float']
         elif issubclass(dtypeobj, _nt.complexfloating):
-            if issubclass(dtypeobj, _nt.clongfloat):
+            if hasattr(_nt, 'clongfloat') and issubclass(dtypeobj, _nt.clongfloat):
                 format_function = formatdict['longcomplexfloat']
             else:
                 format_function = formatdict['complexfloat']

File lib_pypy/numpypy/core/fromnumeric.py

 ######################################################################
 
 import numpypy
+import _numpypy
 
 # Module containing non-deprecated functions borrowed from Numeric.
 __docformat__ = "restructuredtext en"
             [-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):
            [3, 4]])
 
     """
-    raise NotImplementedError('Waiting on interp level method')
+    return _numpypy.repeat(a, repeats, axis)
 
 
 def put(a, ind, v, mode='raise'):

File lib_pypy/numpypy/core/multiarray.py

-from _numpypy import set_string_function, typeinfo
+from _numpypy.multiarray import *

File lib_pypy/numpypy/core/numeric.py

-__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):
         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):
     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.
     """
     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.
     """
     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)

File lib_pypy/numpypy/core/numerictypes.py

+from _numpypy.numerictypes import *

File lib_pypy/numpypy/core/shape_base.py

 __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):
            [4]])
 
     """
-    return _numpypy.concatenate(map(atleast_2d,tup),0)
+    return _nx.concatenate(map(atleast_2d,tup),0)
 
 def hstack(tup):
     """
     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)

File lib_pypy/numpypy/core/umath.py

+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')

File lib_pypy/numpypy/lib/function_base.py

 __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

File lib_pypy/numpypy/lib/shape_base.py

 __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):
     """

File lib_pypy/numpypy/lib/twodim_base.py

 __all__ = ['eye']
 
-from _numpypy import zeros
+from ..core.numeric import zeros
 
 def eye(N, M=None, k=0, dtype=float):
     """

File pypy/doc/cpython_differences.rst

 ``ReferenceError`` at any place that uses them.  (Or, better yet, don't use
 ``weakref.proxy()`` at all; use ``weakref.ref()``.)
 
-There are a few extra implications for the difference in the GC.  Most
+There are a few extra implications from the difference in the GC.  Most
 notably, if an object has a ``__del__``, the ``__del__`` is never called more
 than once in PyPy; but CPython will call the same ``__del__`` several times
 if the object is resurrected and dies again.  The ``__del__`` methods are
 
 .. __: http://bugs.pypy.org/issue736
 
-Using the default GC called ``minimark``, the built-in function ``id()``
+Using the default GC (called ``minimark``), the built-in function ``id()``
 works like it does in CPython.  With other GCs it returns numbers that
 are not real addresses (because an object can move around several times)
 and calling it a lot can lead to performance problem.
 -------------
 
 * Hash randomization (``-R``) is ignored in PyPy.  As documented in
-  http://bugs.python.org/issue14621 , some of us believe it has no
+  http://bugs.python.org/issue14621, some of us believe it has no
   purpose in CPython either.
 
 * ``sys.setrecursionlimit(n)`` sets the limit only approximately,

File pypy/doc/faq.rst

 Be sure to enable it again if you need it!
 
 
-The PyPy translation tool chain
-===============================
+The RPython translation tool chain
+===================================
 
----------------------------------------------
-Can PyPy compile normal Python programs to C?
----------------------------------------------
+------------------------------------------------
+Can RPython compile normal Python programs to C?
+------------------------------------------------
 
-No, PyPy is not a Python compiler.
+No, RPython is not a Python compiler.
 
 In Python, it is mostly impossible to *prove* anything about the types
 that a program will manipulate by doing a static analysis.  It should be
 clear if you are familiar with Python, but if in doubt see [BRETT]_.
 
-If you want a fast Python program, please use our JIT_ instead.
+If you want a fast Python program, please use the PyPy JIT_ instead.
 
 .. _JIT: jit/index.html
 
 Do I have to rewrite my programs in RPython?
 --------------------------------------------
 
-No.  And you shouldn't try.  First and foremost, RPython is a language
-that is designed to write interpreters in.  It is a restricted subset of
+No, and you shouldn't try.  First and foremost, RPython is a language
+designed for writing interpreters. It is a restricted subset of
 Python.  If you program is not an interpreter but tries to do "real
 things", like use *any* part of the standard Python library or *any*
 3rd-party library, then it is not RPython to start with.  You should
 
 No, you have to rebuild the entire interpreter.  This means two things:
 
-* It is imperative to use test-driven development.  You have to test
-  exhaustively your module in pure Python, before even attempting to
+* It is imperative to use test-driven development.  You have to exhaustively
+  test your module in pure Python, before even attempting to
   translate it.  Once you translate it, you should have only a few typing
   issues left to fix, but otherwise the result should work out of the box.
 

File pypy/doc/getting-started-dev.rst

 
 To start the interactive translator shell do::
 
-    cd pypy
+    cd rpython
     python bin/translatorshell.py
 
 Test snippets of translatable code are provided in the file

File pypy/doc/interpreter.rst

 compact bytecode format as CPython 2.7, with minor differences in the bytecode
 set.  Our bytecode compiler is
 implemented as a chain of flexible passes (tokenizer, lexer, parser,
-abstract syntax tree builder, bytecode generator).  The latter passes
+abstract syntax tree builder and bytecode generator).  The latter passes
 are based on the ``compiler`` package from the standard library of
 CPython, with various improvements and bug fixes. The bytecode compiler
 (living under `pypy/interpreter/astcompiler/`_) is now integrated and is
 calling its ``frame.eval()`` method.  This main entry point 
 initialize appropriate namespaces and then interprets each 
 bytecode instruction.  Python's standard library contains
-the `lib-python/2.7/dis.py`_ module which allows to view
-the Virtual's machine bytecode instructions:: 
+the `lib-python/2.7/dis.py`_ module which allows to inspection 
+of the virtual machine's bytecode instructions:: 
 
     >>> import dis
     >>> def f(x):
               6 BINARY_ADD          
               7 RETURN_VALUE        
 
-CPython as well as PyPy are stack-based virtual machines, i.e.
-they don't have registers but put object to and pull objects
+CPython and PyPy are stack-based virtual machines, i.e.
+they don't have registers but instead push object to and pull objects
 from a stack.  The bytecode interpreter is only responsible
-for implementing control flow and putting and pulling black
+for implementing control flow and pushing and pulling black
 box objects to and from this value stack.  The bytecode interpreter 
 does not know how to perform operations on those black box
 (`wrapped`_) objects for which it delegates to the `object
 on ``OperationErrors``. 
 
 The interpreter implementation offers mechanisms to allow a
-caller to be unaware if a particular function invocation leads
-to bytecode interpretation or is executed directly at
+caller to be unaware of whether a particular function invocation 
+leads to bytecode interpretation or is executed directly at
 interpreter-level.  The two basic kinds of `Gateway classes`_
 expose either an interpreter-level function to
 application-level execution (``interp2app``) or allow

File pypy/doc/whatsnew-head.rst

 
 .. branch: numpypy-longdouble
 Long double support for numpypy
+.. branch: numpypy-disable-longdouble
+Since r_longdouble support is missing, disable all longdouble and derivative
+dtypes using ENABLED_LONG_DOUBLE = False
 .. branch: numpypy-real-as-view
 Convert real, imag from ufuncs to views. This involves the beginning of
 view() functionality
 .. branch: task-decorator
 .. branch: fix-e4fa0b2
 .. branch: win32-fixes
+.. branch: numpy-unify-methods
 .. branch: fix-version-tool
 .. branch: popen2-removal
 
 
 .. branch: enumerate-rstr
 Support enumerate() over rstr types.
+
+.. branch: cleanup-numpypy-namespace
+Cleanup _numpypy and numpypy namespaces to more closely resemble numpy.
+
+.. branch: kill-flowobjspace
+Random cleanups to hide FlowObjSpace from public view.

File pypy/goal/multibuild.py

-from pypy.config.pypyoption import get_pypy_config
-from rpython.translator.goal import translate
-from rpython.translator.goal import targetpypystandalone
-from rpython.translator.driver import TranslationDriver
-import os, sys, traceback, random
-
-def longoptfromname(config, name):
-    from pypy.config.makerestdoc import get_cmdline
-    # begin horror
-    h, n = config._cfgimpl_get_home_by_path(name)
-    opt = getattr(h._cfgimpl_descr, n)
-    # end horror
-    cmdline = get_cmdline(opt.cmdline, name)
-    assert cmdline is not None
-    shortest_long_option = 'X'*1000
-    for cmd in cmdline.split():
-        if cmd.startswith('--') and len(cmd) < len(shortest_long_option):
-            shortest_long_option = cmd
-    return shortest_long_option
-
-def exe_name_from_options(config, opts):
-    from pypy.module.sys.version import svn_revision
-
-    backend = config.translation.backend
-    if not backend:
-        backend = 'c'
-    rev = svn_revision()
-
-    nameparts = []
-
-    for opt, v in opts.iteritems():
-        if opt == 'translation.backend':
-            backend = v
-        optname = longoptfromname(config, opt).strip('-')
-        if v is False:
-            optname = 'no-' + optname
-        elif v is not True:
-            optname += '=' + str(v)
-        nameparts.append(optname)
-
-    suffix = ''
-    if nameparts:
-        def k(s):
-            if s.startswith('no-'):
-                return s[3:]
-            else:
-                return s
-        nameparts.sort(key=k)
-        suffix = '-' + '-'.join(nameparts)
-
-    return 'pypy-%s-%d%s'%(backend, rev, suffix)
-
-def _build(config, exe_name):
-    driver = TranslationDriver.from_targetspec(
-        targetpypystandalone.__dict__,
-        config=config)
-    driver.exe_name = exe_name
-    driver.compile()
-
-def build_pypy_with_options(basedir, opts):
-    config = get_pypy_config(translate.OVERRIDES, translating=True)
-
-    try:
-        config.set(**opts)
-    except:
-        return exe_name_from_options(config, opts), "didn't configure"
-
-    exe_name = os.path.join(basedir, exe_name_from_options(config, opts))
-
-    print exe_name,
-    sys.stdout.flush()
-
-    pid = os.fork()
-
-    if pid == 0:
-        logfile = open(exe_name + '-log', 'w')
-        davenull = os.open('/dev/null', os.O_RDONLY)
-        os.dup2(davenull, 0)
-        os.dup2(logfile.fileno(), 1)
-        os.dup2(logfile.fileno(), 2)
-        try:
-            try:
-                r = _build(config, exe_name)
-            finally:
-                logfile.close()
-        except:
-            os._exit(1)
-        else:
-            os._exit(0)
-    else:
-        pid, status = os.waitpid(pid, 0)
-        if status:
-            r = 'failed'
-        else:
-            r = 'succeeded'
-        print r
-        return exe_name, r
-
-def get_options(fname):
-    def gen_opts(sofar, remaining):
-        if not remaining:
-            yield sofar
-        else:
-            for (k, v) in remaining[0]:
-                d2 = sofar.copy()
-                d2[k] = v
-                for d in gen_opts(d2, remaining[1:]):
-                    yield d
-    options = []
-    for line in open(fname):
-        l = []
-        optname, options_ = line.split(':')
-        options.append([(optname.strip(), eval(optval.strip())) for optval in options_.split(',')])
-    return gen_opts({}, options)
-
-
-if __name__ == '__main__':
-    basedir = sys.argv[1]
-    optionsfile = sys.argv[2]
-    results = []
-    options = list(get_options(optionsfile))
-    random.shuffle(options)
-    for opts in options:
-        results.append(build_pypy_with_options(basedir, opts))
-    out = open(os.path.join(basedir, 'results'), 'w')
-    for exe, r in results:
-        print >>out, exe, r

File pypy/module/micronumpy/__init__.py

 from pypy.interpreter.mixedmodule import MixedModule
-from pypy.module.micronumpy.interp_boxes import long_double_size
+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',
         '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',
         'float16': 'interp_boxes.W_Float16Box',
         'float32': 'interp_boxes.W_Float32Box',
         'float64': 'interp_boxes.W_Float64Box',
-        'longdouble': 'interp_boxes.W_LongDoubleBox',
-        'longfloat': 'interp_boxes.W_LongDoubleBox',
         'intp': 'types.IntP.BoxType',
         'uintp': 'types.UIntP.BoxType',
         'flexible': 'interp_boxes.W_FlexibleBox',
         'complex_': 'interp_boxes.W_Complex128Box',
         'complex128': 'interp_boxes.W_Complex128Box',
         'complex64': 'interp_boxes.W_Complex64Box',
-        'clongdouble': 'interp_boxes.W_CLongDoubleBox',
-        'clongfloat': 'interp_boxes.W_CLongDoubleBox',
     }
+    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"),
     ]:
         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 long_double_size == 16:
-    Module.interpleveldefs['float128'] = 'interp_boxes.W_Float128Box'
-    Module.interpleveldefs['complex256'] = 'interp_boxes.W_Complex256Box'
-elif long_double_size == 12:
-    Module.interpleveldefs['float96'] = 'interp_boxes.W_Float96Box'
-    Module.interpleveldefs['complex192'] = 'interp_boxes.W_Complex192Box'
+    submodules = {
+        'multiarray': MultiArrayModule,
+        'numerictypes': NumericTypesModule,
+        'umath': UMathModule,
+    }

File pypy/module/micronumpy/app_numpy.py

         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

File pypy/module/micronumpy/interp_arrayops.py

     args_w = [convert_to_array(space, w_arg) for w_arg in args_w]
     dtype = args_w[0].get_dtype()
     shape = args_w[0].get_shape()[:]
-    if len(shape) <= axis:
+    _axis = axis
+    if axis < 0:
+        _axis = len(shape) + axis
+    if _axis < 0 or len(shape) <= _axis:
         raise operationerrfmt(space.w_IndexError, "axis %d out of bounds [0, %d)", axis, len(shape))
     for arr in args_w[1:]:
         dtype = interp_ufuncs.find_binop_result_dtype(space, dtype,
                                                       arr.get_dtype())
-        if len(arr.get_shape()) <= axis:
+        if _axis < 0 or len(arr.get_shape()) <= _axis:
             raise operationerrfmt(space.w_IndexError, "axis %d out of bounds [0, %d)", axis, len(shape))
         for i, axis_size in enumerate(arr.get_shape()):
-            if len(arr.get_shape()) != len(shape) or (i != axis and axis_size != shape[i]):
+            if len(arr.get_shape()) != len(shape) or (i != _axis and axis_size != shape[i]):
                 raise OperationError(space.w_ValueError, space.wrap(
                     "all the input arrays must have same number of dimensions"))
-            elif i == axis:
+            elif i == _axis:
                 shape[i] += axis_size
     res = W_NDimArray.from_shape(shape, dtype, 'C')
     chunks = [Chunk(0, i, 1, i) for i in shape]
     axis_start = 0
     for arr in args_w:
-        if arr.get_shape()[axis] == 0:
+        if arr.get_shape()[_axis] == 0:
             continue
-        chunks[axis] = Chunk(axis_start, axis_start + arr.get_shape()[axis], 1,
-                             arr.get_shape()[axis])
+        chunks[_axis] = Chunk(axis_start, axis_start + arr.get_shape()[_axis], 1,
+                             arr.get_shape()[_axis])
         Chunks(chunks).apply(res).implementation.setslice(space, arr)
-        axis_start += arr.get_shape()[axis]
+        axis_start += arr.get_shape()[_axis]
     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)
 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):
+@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,

File pypy/module/micronumpy/interp_boxes.py

 MIXIN_64 = (int_typedef,) if LONG_BIT == 64 else ()
 
 # Is this the proper place for this?
+ENABLED_LONG_DOUBLE = False
 long_double_size = rffi.sizeof_c_type('long double', ignore_errors=True)
+
 import os
 if long_double_size == 8 and os.name == 'nt':
-    # this is a lie, or maybe a wish
+    # this is a lie, or maybe a wish, MS fakes longdouble math with double
     long_double_size = 12
 
 
     descr__new__, _get_dtype = new_dtype_getter("complex128")
     _COMPONENTS_BOX = W_Float64Box
 
-if long_double_size == 12:
+if ENABLED_LONG_DOUBLE and long_double_size == 12:
     class W_Float96Box(W_FloatingBox, PrimitiveBox):
         descr__new__, _get_dtype = new_dtype_getter("float96")
 
 
     W_CLongDoubleBox = W_Complex192Box
 
-elif long_double_size == 16:
+elif ENABLED_LONG_DOUBLE and long_double_size == 16:
     class W_Float128Box(W_FloatingBox, PrimitiveBox):
         descr__new__, _get_dtype = new_dtype_getter("float128")
     W_LongDoubleBox = W_Float128Box
 
     W_CLongDoubleBox = W_Complex256Box
 
-else:
+elif ENABLED_LONG_DOUBLE:
     W_LongDoubleBox = W_Float64Box
     W_CLongDoubleBox = W_Complex64Box
 
     __new__ = interp2app(W_Float64Box.descr__new__.im_func),
 )
 
-if long_double_size == 12:
+if ENABLED_LONG_DOUBLE and long_double_size == 12:
     W_Float96Box.typedef = TypeDef("float96", (W_FloatingBox.typedef),
         __module__ = "numpypy",
 
         imag = GetSetProperty(W_ComplexFloatingBox.descr_get_imag),
     )
 
-elif long_double_size == 16:
+elif ENABLED_LONG_DOUBLE and long_double_size == 16:
     W_Float128Box.typedef = TypeDef("float128", (W_FloatingBox.typedef),
         __module__ = "numpypy",
 

File pypy/module/micronumpy/interp_dtype.py

     def is_record_type(self):
         return self.fields is not None
 
+    def is_str_or_unicode(self):
+        return (self.num == 18 or self.num == 19)
+
     def is_flexible_type(self):
-        return (self.num == 18 or self.num == 19 or self.num == 20)
+        return (self.is_str_or_unicode() or self.is_record_type())
 
     def __repr__(self):
         if self.fields is not None:
             w_box_type=space.gettypefor(interp_boxes.W_ULongBox),
             alternate_constructors=[ space.gettypefor(interp_boxes.W_UnsignedIntegerBox),
                                    ],
+            aliases=['uint'],
         )
         self.w_int64dtype = W_Dtype(
             types.Int64(),
             aliases=["complex"],
             float_type = self.w_float64dtype,
         )
-        if interp_boxes.long_double_size == 12:
+        if interp_boxes.ENABLED_LONG_DOUBLE and interp_boxes.long_double_size == 12:
             self.w_float96dtype = W_Dtype(
                 types.Float96(),
                 num=13,
             )
             self.w_longdouble = self.w_float96dtype
             self.w_clongdouble = self.w_complex192dtype
-        elif interp_boxes.long_double_size == 16:
+        elif interp_boxes.ENABLED_LONG_DOUBLE and interp_boxes.long_double_size == 16:
             self.w_float128dtype = W_Dtype(
                 types.Float128(),
                 num=13,
             )
             self.w_longdouble = self.w_float128dtype
             self.w_clongdouble = self.w_complex256dtype
-        else:
+        elif interp_boxes.ENABLED_LONG_DOUBLE:
             self.w_float64dtype.aliases += ["longdouble", "longfloat"]
             self.w_complex128dtype.aliases += ["clongdouble", "clongfloat"]
             self.w_longdouble = self.w_float64dtype
             self.w_clongdouble = self.w_complex128dtype
         self.w_stringdtype = W_Dtype(
-            types.StringType(1),
+            types.StringType(0),
             num=18,
             kind=STRINGLTR,
             name='string',
             char=UINTPLTR,
             w_box_type = space.gettypefor(uintp_box),
         )
+        float_dtypes = [self.w_float16dtype,
+                self.w_float32dtype, self.w_float64dtype,
+                ]
+        complex_dtypes =  [self.w_complex64dtype, self.w_complex128dtype]
+        if interp_boxes.ENABLED_LONG_DOUBLE:
+            float_dtypes.append(self.w_longdouble)
+            complex_dtypes.append(self.w_clongdouble)
         self.builtin_dtypes = [
             self.w_booldtype,
             self.w_int8dtype, self.w_uint8dtype,
             self.w_int16dtype, self.w_uint16dtype,
             self.w_longdtype, self.w_ulongdtype,
             self.w_int32dtype, self.w_uint32dtype,
-            self.w_int64dtype, self.w_uint64dtype,
-            self.w_float16dtype,
-            self.w_float32dtype, self.w_float64dtype, self.w_longdouble,
-            self.w_complex64dtype, self.w_complex128dtype, self.w_clongdouble,
+            self.w_int64dtype, self.w_uint64dtype] + \
+            float_dtypes + complex_dtypes + [
             self.w_stringdtype, self.w_unicodedtype, self.w_voiddtype,
             self.w_intpdtype, self.w_uintpdtype,
         ]
         self.float_dtypes_by_num_bytes = sorted(
             (dtype.itemtype.get_element_size(), dtype)
-            for dtype in [self.w_float16dtype, self.w_float32dtype,
-                          self.w_float64dtype, self.w_longdouble]
+            for dtype in float_dtypes
         )
         self.dtypes_by_num = {}
         self.dtypes_by_name = {}
             'LONGLONG': self.w_int64dtype,
             'SHORT': self.w_int16dtype,
             'VOID': self.w_voiddtype,
-            'LONGDOUBLE': self.w_longdouble,
             'UBYTE': self.w_uint8dtype,
             'UINTP': self.w_ulongdtype,
             'ULONG': self.w_ulongdtype,
             'USHORT': self.w_uint16dtype,
             'FLOAT': self.w_float32dtype,
             'BOOL': self.w_booldtype,
-            'CLONGDOUBLE': self.w_clongdouble,
         }
+        if interp_boxes.ENABLED_LONG_DOUBLE:
+            typeinfo_full['LONGDOUBLE'] = self.w_longdouble
+            typeinfo_full['CLONGDOUBLE'] = self.w_clongdouble
+
         typeinfo_partial = {
             'Generic': interp_boxes.W_GenericBox,
             'Character': interp_boxes.W_CharacterBox,

File pypy/module/micronumpy/interp_numarray.py

 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
             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):
         return w_object
 
     shape, elems_w = find_shape_and_elems(space, w_object, dtype)
-    if dtype is None:
+    if dtype is None or (
+                 dtype.is_str_or_unicode() and dtype.itemtype.get_size() < 1):
         for w_elem in elems_w:
             dtype = interp_ufuncs.find_dtype_for_scalar(space, w_elem,
                                                         dtype)
 
         if dtype is None:
             dtype = interp_dtype.get_dtype_cache(space).w_float64dtype
+    if dtype.is_str_or_unicode() and dtype.itemtype.get_size() < 1:
+        # promote S0 -> S1, U0 -> U1
+        dtype = interp_dtype.variable_dtype(space, dtype.char + '1')
     if ndmin > len(shape):
         shape = [1] * (ndmin - len(shape)) + shape
     arr = W_NDimArray.from_shape(shape, dtype, order=order)

File pypy/module/micronumpy/interp_ufuncs.py

         if w_obj.get_dtype().is_flexible_type():
             raise OperationError(space.w_TypeError, 
                       space.wrap('Not implemented for this type'))
+        if self.int_only and not w_obj.get_dtype().is_int_type():
+            raise OperationError(space.w_TypeError, space.wrap(
+                "ufunc %s not supported for the input type" % self.name))
         calc_dtype = find_unaryop_result_dtype(space,
                                   w_obj.get_dtype(),
                                   promote_to_float=self.promote_to_float,
             promote_bools=self.promote_bools,
             allow_complex=self.allow_complex,
             )
+        if self.int_only and not calc_dtype.is_int_type():
+            raise OperationError(space.w_TypeError, space.wrap(
+                "ufunc '%s' not supported for the input types" % self.name))
         if space.is_none(w_out):
             out = None
         elif not isinstance(w_out, W_NDimArray):
             return interp_dtype.get_dtype_cache(space).w_complex64dtype
         elif dt2.num == 15:
             return interp_dtype.get_dtype_cache(space).w_complex128dtype
-        elif dt2.num == 16:
+        elif interp_boxes.ENABLED_LONG_DOUBLE and dt2.num == 16:
             return interp_dtype.get_dtype_cache(space).w_clongdouble
         else:
             raise OperationError(space.w_TypeError, space.wrap("Unsupported types"))

File pypy/module/micronumpy/test/test_arrayops.py

 
 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)
     #    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
 
 
     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
 
         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):
         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()
         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')
         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)

File pypy/module/micronumpy/test/test_base.py

             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)
 

File pypy/module/micronumpy/test/test_complex.py

             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),
         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),
         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, clongdouble
-
+        from numpypy import array, reciprocal, complex64, complex128
+        c_and_relerr = [(complex64, 2e-7), (complex128, 2e-15)]
+        try:
+            from numpypy import clongdouble
+            c_and_relerr.append((clongdouble, 2e-30))
+        except:
+            pass # no longdouble yet
         inf = float('inf')
         nan = float('nan')
         #complex    
                     complex(-r, i), 
                     -0j, 0j, cnan, 
                     cnan, cnan, cnan]
-        for c, rel_err in ((complex64, 2e-7), (complex128, 2e-15), (clongdouble, 2e-15)):
+        for c, rel_err in c_and_relerr:
             actual = reciprocal(array([orig], dtype=c))
             for b, a, e in zip(orig, actual, expected):
                 assert (a[0].real - e.real) < rel_err
                 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, clongfloat
+        from numpypy import array, exp2, complex128, complex64
+        c_and_relerr = [(complex64, 2e-7), (complex128, 2e-15)]
+        try:
+            from numpypy import clongdouble
+            c_and_relerr.append((clongdouble, 2e-30))
+        except:
+            pass # no longdouble yet
         inf = float('inf')
         ninf = -float('inf')
         nan = float('nan')
         cmpl = complex
-        for c,rel_err in ((complex128, 2e-15), (complex64, 1e-7), (clongfloat, 2e-15)):
+        for c,rel_err in c_and_relerr:
             a = [cmpl(-5., 0), cmpl(-5., -5.), cmpl(-5., 5.),
                        cmpl(0., -5.), cmpl(0., 0.), cmpl(0., 5.),
                        cmpl(-0., -5.), cmpl(-0., 0.), cmpl(-0., 5.),
 
     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')
                 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))
         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)) == \
 
 
     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):
         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
                     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))
     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')
                 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)
         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])
             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])
             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, clongfloat)
-        from _numpypy import (equal, not_equal, greater, greater_equal, less,
+            floor_divide, real, imag, sign)
+        from numpypy import (equal, not_equal, greater, greater_equal, less,
                 less_equal, isnan)
+        complex_dtypes = [complex64, complex128]
+        try:
+            from numpypy import clongfloat
+            complex_dtypes.append(clongfloat)
+        except:
+            pass
         assert real(4.0) == 4.0
         assert imag(0.0) == 0.0
         a = array([complex(3.0, 4.0)])
         b = a.real
         assert b.dtype == dtype(float)
-        for complex_ in complex64, complex128, clongfloat:
+        for complex_ in complex_dtypes:
 
             O = complex(0, 0)
             c0 = complex_(complex(2.5, 0))
             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()
         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 (\

File pypy/module/micronumpy/test/test_dtypes.py

             from rpython.rtyper.lltypesystem import rffi
             ptr_size = rffi.sizeof(rffi.CCHARP)
         cls.w_ptr_size = cls.space.wrap(ptr_size)
-
+    
 class AppTestDtypes(BaseAppTestDtypes):
     def test_dtype(self):
-        from _numpypy import dtype
+        from numpypy import dtype
 
         d = dtype('?')
         assert d.num == 0
         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")
         raises(TypeError, lambda: dtype("int8") == 3)
         assert dtype(bool) == bool
 
-    def test_dtype_aliases(self):
-        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_dtype_with_types(self):
-        from _numpypy import dtype
+        from numpypy import dtype
 
         assert dtype(bool).num == 0
         if self.ptr_size == 4:
             assert dtype('int64').num == 7
             assert dtype('uint64').num == 8
         assert dtype(int).num == 7
+        assert dtype('int').num == 7
+        assert dtype('uint').num == 8
         assert dtype(float).num == 12
+        assert dtype('float').num == 12
+        assert dtype('complex').num == 15
 
     def test_array_dtype_attr(self):
-        from _numpypy import array, dtype
+        from numpypy import array, dtype
 
         a = array(list(range(5)), int)
         assert a.dtype is dtype(int)
 
     def test_repr_str(self):
-        from _numpypy import dtype
+        from numpypy import dtype
 
         assert '.dtype' in repr(dtype)
         d = dtype('?')
         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_
             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=int)
         # int on 64-bit, long in 32-bit
         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=int)
         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=int)
         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
         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'
         ]
-        if array([0], dtype='longdouble').itemsize > 8:
-            types += ['g', 'G']
         a = array([True], '?')
         for t in types:
             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'),
             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(list(range(5)), dtype="int8")
         b = a + a
             assert b[i] == i * 2
 
     def test_add_int16(self):
-        from _numpypy import array, dtype
+        from numpypy import array, dtype
 
         a = array(list(range(5)), dtype="int16")
         b = a + a
             assert b[i] == i * 2
 
     def test_add_uint32(self):
-        from _numpypy import array, dtype
+        from numpypy import array, dtype
 
         a = array(list(range(5)), dtype="I")
         b = a + a
             assert b[i] == i * 2
 
     def test_shape(self):
-        from _numpypy import dtype
+        from numpypy import dtype
 
         assert dtype(int).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)
             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),
             (numpy.float16, 10.),
             (numpy.float32, 2.0),
             (numpy.float64, 4.32),
-            (numpy.longdouble, 4.32),
         ]:
             assert hash(tp(value)) == hash(value)
 
 
 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)
         #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_
         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, 
         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, 
         assert numpy.uint8('256') == 0
 
     def test_int16(self):
-        import _numpypy as numpy
+        import numpypy as numpy
 
         x = numpy.int16(3)
         assert x == 3
         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
 
     def test_int32(self):
         import sys
-        import _numpypy as numpy
+        import numpypy as numpy
 
         x = numpy.int32(23)
         assert x == 23
 
     def test_uint32(self):
         import sys
-        import _numpypy as numpy
+        import numpypy as numpy
 
         assert numpy.uint32(10) == 10
 
             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, 
 
     def test_int64(self):
         import sys
-        import _numpypy as numpy
+        import numpypy as numpy
 
         if sys.maxsize == 2 ** 63 -1:
             assert numpy.int64.mro() == [numpy.int64, numpy.signedinteger, 
 
     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, 
         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]
 
 
     def test_float32(self):
-        import _numpypy as numpy
+        import numpypy as numpy
 
         assert numpy.float32.mro() == [numpy.float32, numpy.floating, 
                                        numpy.inexact, numpy.number, 
         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, 
         raises(ValueError, numpy.float64, '23.2df')
 
     def test_float_None(self):
-        import _numpypy as numpy
+        import numpypy as numpy
         from math import isnan