Author: Brian Kearns <[email protected]>
Branch: cleanup-numpypy-namespace
Changeset: r61756:5369e4d98df9
Date: 2013-02-25 07:07 -0500
http://bitbucket.org/pypy/pypy/changeset/5369e4d98df9/
Log: update app-level code for _numpypy submodules
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,5 +1,3 @@
-import _numpypy
-from _numpypy import *
import numeric
from numeric import *
import fromnumeric
@@ -8,10 +6,9 @@
from shape_base import *
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/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,21 +1,20 @@
__all__ = [
- 'ufunc',
- 'asanyarray', 'base_repr',
+ 'newaxis', 'ufunc',
+ 'asarray', 'asanyarray', 'base_repr',
'array_repr', 'array_str', 'set_string_function',
- 'array_equal', 'asarray', 'outer', 'identity', 'little_endian',
+ '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, sin
-from .fromnumeric import any
import sys
import multiarray
+from multiarray import *
+del set_string_function
+del typeinfo
import umath
from umath import *
-from numpypy.core.arrayprint import array2string
-
-ufunc = type(sin)
+import numerictypes
+from numerictypes import *
def extend_all(module):
adict = {}
@@ -29,9 +28,13 @@
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):
@@ -142,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):
@@ -327,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.
@@ -438,16 +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
-nan = NaN = NAN
-False_ = bool_(False)
-True_ = bool_(True)
-
def outer(a,b):
"""
Compute the outer product of two vectors.
@@ -551,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/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
--- a/lib_pypy/numpypy/core/umath.py
+++ b/lib_pypy/numpypy/core/umath.py
@@ -1,3 +1,5 @@
+from _numpypy.umath import *
+
import math
e = math.e
pi = math.pi
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):
"""
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit