Author: Brian Kearns <[email protected]>
Branch: cleanup-numpypy-namespace
Changeset: r61755:b8c9382cbad4
Date: 2013-02-25 08:04 -0500
http://bitbucket.org/pypy/pypy/changeset/b8c9382cbad4/
Log: split _numpypy into submodules
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,9 +2,8 @@
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',
@@ -23,7 +22,12 @@
'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',
@@ -67,7 +71,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"),
@@ -149,35 +176,13 @@
]:
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
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
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit