Commits

Brian Kearns committed b8c9382

split _numpypy into submodules

Comments (0)

Files changed (2)

pypy/module/micronumpy/__init__.py

 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',
 
         'set_string_function': 'appbridge.set_string_function',
         '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',
         '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"),
     ]:
         interpleveldefs[exposed] = "interp_ufuncs.get(space).%s" % impl
 
-    appleveldefs = {
-        'arange': 'app_numpy.arange',
+
+class Module(MixedModule):
+    applevel_name = '_numpypy'
+    appleveldefs = {}
+    interpleveldefs = {}
+    submodules = {
+        'multiarray': MultiArrayModule,
+        'numerictypes': NumericTypesModule,
+        'umath': UMathModule,
     }
-    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

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