[pypy-commit] pypy default: fix tests for -A

2012-12-12 Thread mattip
Author: mattip 
Branch: 
Changeset: r59410:5b0bb368c5e1
Date: 2012-12-12 14:35 -0800
http://bitbucket.org/pypy/pypy/changeset/5b0bb368c5e1/

Log:fix tests for -A

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
@@ -94,30 +94,42 @@
 cls.w_testcases128 = cls.space.wrap(list(parse_testfile(fname128)))
 cls.w_testcases64 = cls.space.wrap(list(parse_testfile(fname64)))
 
-def cls_c_pow(space, args_w):
-try:
-retVal = c_pow(*map(space.unwrap, args_w))
-return space.wrap(retVal)
-except ValueError, e:
-if option.runappdirect:
-raise
-raise OperationError(cls.space.w_ValueError,
-cls.space.wrap(e.message))
-cls.w_c_pow = cls.space.wrap(interp2app(cls_c_pow))
 cls.w_runAppDirect = cls.space.wrap(option.runappdirect)
 cls.w_isWindows = cls.space.wrap(os.name == 'nt')
 
-def cls_rAlmostEqual(space, __args__):
-args, kwargs = __args__.unpack()
-args = map(space.unwrap, args)
-kwargs = dict([
-(k, space.unwrap(v))
-for k, v in kwargs.iteritems()
-])
-if '__pypy__' not in sys.builtin_module_names:
-kwargs['isnumpy'] = True
-return space.wrap(rAlmostEqual(*args, **kwargs))
-cls.w_rAlmostEqual = cls.space.wrap(interp2app(cls_rAlmostEqual))
+if cls.runappdirect:
+def cls_rAlmostEqual(space, *args, **kwargs):
+return rAlmostEqual(*args, **kwargs)
+cls.w_rAlmostEqual = cls.space.wrap(cls_rAlmostEqual)
+def cls_c_pow(space, *args):
+return c_pow(*args)
+cls.w_c_pow = cls.space.wrap(cls_c_pow)
+else:
+def cls_rAlmostEqual(space, __args__):
+args, kwargs = __args__.unpack()
+args = map(space.unwrap, args)
+kwargs = dict([
+(k, space.unwrap(v))
+for k, v in kwargs.iteritems()
+])
+if '__pypy__' not in sys.builtin_module_names:
+kwargs['isnumpy'] = True
+return space.wrap(rAlmostEqual(*args, **kwargs))
+cls.w_rAlmostEqual = cls.space.wrap(interp2app(cls_rAlmostEqual))
+def cls_c_pow(space, args_w):
+try:
+retVal = c_pow(*map(space.unwrap, args_w))
+return space.wrap(retVal)
+except ZeroDivisionError, e:
+raise OperationError(cls.space.w_ZeroDivisionError,
+cls.space.wrap(e.message))
+except OverflowError, e:
+raise OperationError(cls.space.w_OverflowError,
+cls.space.wrap(e.message))
+except ValueError, e:
+raise OperationError(cls.space.w_ValueError,
+cls.space.wrap(e.message))
+cls.w_c_pow = cls.space.wrap(interp2app(cls_c_pow))
 
 def test_fabs(self):
 from _numpypy import fabs, complex128
___
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy numpypy-longdouble: add failing tests for float128 (64 bit linux)

2012-12-12 Thread mattip
Author: mattip 
Branch: numpypy-longdouble
Changeset: r59409:bd6c0279e8fb
Date: 2012-12-12 13:50 -0800
http://bitbucket.org/pypy/pypy/changeset/bd6c0279e8fb/

Log:add failing tests for float128 (64 bit linux)

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
@@ -1,4 +1,5 @@
 from pypy.interpreter.mixedmodule import MixedModule
+from pypy.module.micronumpy.interp_boxes import long_double_size
 
 
 class Module(MixedModule):
@@ -165,3 +166,8 @@
 'max': 'app_numpy.max',
 'arange': 'app_numpy.arange',
 }
+
+if long_double_size == 16:
+Module.interpleveldefs['float128'] = 'interp_boxes.W_Float128Box'
+elif long_double_size == 12:
+Module.interpleveldefs['float96'] = 'interp_boxes.W_Float96Box'
diff --git a/pypy/module/micronumpy/interp_dtype.py 
b/pypy/module/micronumpy/interp_dtype.py
--- a/pypy/module/micronumpy/interp_dtype.py
+++ b/pypy/module/micronumpy/interp_dtype.py
@@ -430,7 +430,7 @@
 kind=FLOATINGLTR,
 name="float128",
 char="g",
-w_box_type=space.gettypefor(interp_boxes.W_Floati128Box),
+w_box_type=space.gettypefor(interp_boxes.W_Float128Box),
 aliases=["longfloat", "longdouble"],
 )
 longdouble = self.w_float128dtype
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
@@ -2110,7 +2110,7 @@
 
 def test_fromstring_types(self):
 from _numpypy import (fromstring, int8, int16, int32, int64, uint8,
-uint16, uint32, float16, float32, float64)
+uint16, uint32, float16, float32, float64, longfloat, array)
 a = fromstring('\xFF', dtype=int8)
 assert a[0] == -1
 b = fromstring('\xFF', dtype=uint8)
@@ -2133,12 +2133,18 @@
 assert j[0] == 12
 k = fromstring(self.float16val, dtype=float16)
 assert k[0] == float16(5.)
-try:
+dt =  array([5],dtype=longfloat).dtype
+if dt.itemsize == 12:
 from _numpypy import float96
-except:
-skip('no float96 on this platform/compiler, maybe try float128?')
-k = fromstring('\x00\x00\x00\x00\x00\x00\x00\xa0\x01@\x00\x00', 
dtype=float96)
-assert k[0] == float96(5.)
+m = fromstring('\x00\x00\x00\x00\x00\x00\x00\xa0\x01@\x00\x00', 
dtype=float96)
+elif dt.itemsize==16:
+from _numpypy import float128
+m = 
fromstring('\x00\x00\x00\x00\x00\x00\x00\xa0\x01@\x9c\xd3#\x7f\x00\x00', 
dtype=float128)
+elif dt.itemsize == 8:
+skip('longfloat is float64')
+else:
+skip('unknown itemsize for longfloat')
+assert m[0] == longfloat(5.)
 
 def test_fromstring_invalid(self):
 from _numpypy import fromstring, uint16, uint8, int32
diff --git a/pypy/module/micronumpy/types.py b/pypy/module/micronumpy/types.py
--- a/pypy/module/micronumpy/types.py
+++ b/pypy/module/micronumpy/types.py
@@ -989,12 +989,10 @@
 BoxType = interp_boxes.W_Float96Box
 format_code = "q"
 
-class NonNativeFloat96(BaseType, NonNativeFloat):
-_attrs_ = ()
+class NonNativeFloat96(Float96):
+pass
 
-T = rffi.LONGDOUBLE
-BoxType = interp_boxes.W_Float96Box
-format_code = "q"
+
 elif interp_boxes.long_double_size == 16:
 class Float128(BaseType, Float):
 _attrs_ = ()
@@ -1003,12 +1001,14 @@
 BoxType = interp_boxes.W_Float128Box
 format_code = "q"
 
-class NonNativeFloat128(BaseType, NonNativeFloat):
-_attrs_ = ()
+def runpack_str(self, s):
+assert len(s) == 16
+fval = unpack_float(s, native_is_bigendian)
+return self.box(fval)
 
-T = rffi.LONGDOUBLE
-BoxType = interp_boxes.W_Float128Box
-format_code = "q"
+class NonNativeFloat128(Float128):
+pass
+
 
 class ComplexFloating(object):
 _mixin_ = True
___
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit