Author: mattip <[email protected]>
Branch: numpypy-disable-longdouble
Changeset: r61559:5980ccbb798c
Date: 2013-02-14 11:05 +0200
http://bitbucket.org/pypy/pypy/changeset/5980ccbb798c/
Log: remove longdouble and related dtypes, start to move tests
accordingly
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
@@ -62,8 +62,8 @@
'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',
+ # 'longdouble': 'interp_boxes.W_LongDoubleBox',
+ # 'longfloat': 'interp_boxes.W_LongDoubleBox',
'intp': 'types.IntP.BoxType',
'uintp': 'types.UIntP.BoxType',
'flexible': 'interp_boxes.W_FlexibleBox',
@@ -76,8 +76,8 @@
'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',
+ # 'clongdouble': 'interp_boxes.W_CLongDoubleBox',
+ # 'clongfloat': 'interp_boxes.W_CLongDoubleBox',
}
# ufuncs
@@ -172,9 +172,9 @@
'arange': 'app_numpy.arange',
}
-if long_double_size == 16:
+if 0 and long_double_size == 16:
Module.interpleveldefs['float128'] = 'interp_boxes.W_Float128Box'
Module.interpleveldefs['complex256'] = 'interp_boxes.W_Complex256Box'
-elif long_double_size == 12:
+elif 0 and long_double_size == 12:
Module.interpleveldefs['float96'] = 'interp_boxes.W_Float96Box'
Module.interpleveldefs['complex192'] = 'interp_boxes.W_Complex192Box'
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
@@ -474,7 +474,7 @@
aliases=["complex"],
float_type = self.w_float64dtype,
)
- if interp_boxes.long_double_size == 12:
+ if 0 and interp_boxes.long_double_size == 12:
self.w_float96dtype = W_Dtype(
types.Float96(),
num=13,
@@ -497,7 +497,7 @@
)
self.w_longdouble = self.w_float96dtype
self.w_clongdouble = self.w_complex192dtype
- elif interp_boxes.long_double_size == 16:
+ elif 0 and interp_boxes.long_double_size == 16:
self.w_float128dtype = W_Dtype(
types.Float128(),
num=13,
@@ -520,7 +520,7 @@
)
self.w_longdouble = self.w_float128dtype
self.w_clongdouble = self.w_complex256dtype
- else:
+ elif 0:
self.w_float64dtype.aliases += ["longdouble", "longfloat"]
self.w_complex128dtype.aliases += ["clongdouble", "clongfloat"]
self.w_longdouble = self.w_float64dtype
@@ -604,15 +604,19 @@
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_float32dtype, self.w_float64dtype,
+ # self.w_longdouble,
+ self.w_complex64dtype, self.w_complex128dtype,
+ # self.w_clongdouble,
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]
+ self.w_float64dtype,
+ # self.w_longdouble,
+ ]
)
self.dtypes_by_num = {}
self.dtypes_by_name = {}
@@ -655,7 +659,7 @@
'LONGLONG': self.w_int64dtype,
'SHORT': self.w_int16dtype,
'VOID': self.w_voiddtype,
- 'LONGDOUBLE': self.w_longdouble,
+ #'LONGDOUBLE': self.w_longdouble,
'UBYTE': self.w_uint8dtype,
'UINTP': self.w_ulongdtype,
'ULONG': self.w_ulongdtype,
@@ -678,7 +682,7 @@
'USHORT': self.w_uint16dtype,
'FLOAT': self.w_float32dtype,
'BOOL': self.w_booldtype,
- 'CLONGDOUBLE': self.w_clongdouble,
+ #'CLONGDOUBLE': self.w_clongdouble,
}
typeinfo_partial = {
'Generic': interp_boxes.W_GenericBox,
diff --git a/pypy/module/micronumpy/test/test_dtypes.py
b/pypy/module/micronumpy/test/test_dtypes.py
--- a/pypy/module/micronumpy/test/test_dtypes.py
+++ b/pypy/module/micronumpy/test/test_dtypes.py
@@ -14,7 +14,7 @@
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
@@ -530,19 +530,6 @@
assert isnan(numpy.float64(None))
assert isnan(numpy.longdouble(None))
- def test_longfloat(self):
- import _numpypy as numpy
- # it can be float96 or float128
- if numpy.longfloat != numpy.float64:
- assert numpy.longfloat.mro()[1:] == [numpy.floating,
- numpy.inexact, numpy.number,
- numpy.generic, object]
- a = numpy.array([1, 2, 3], numpy.longdouble)
- assert type(a[1]) is numpy.longdouble
- assert numpy.float64(12) == numpy.longdouble(12)
- assert numpy.float64(12) == numpy.longfloat(12)
- raises(ValueError, numpy.longfloat, '23.2df')
-
def test_complex_floating(self):
import _numpypy as numpy
@@ -821,3 +808,48 @@
assert typeinfo['LONGLONG'] == ('q', 9, 64, 8, 9223372036854775807L,
-9223372036854775808L, int64)
assert typeinfo['VOID'] == ('V', 20, 0, 1, void)
assert typeinfo['BOOL'] == ('?', 0, 8, 1, 1, 0, bool_)
+
+class AppTestNoLongDoubleDtypes(BaseNumpyAppTest):
+ def setup_class(cls):
+ from pypy.module.micronumpy import Module
+ if Module.interpleveldefs.get('longfloat', None):
+ py.test.skip('longdouble exists, skip these tests')
+ if option.runappdirect and '__pypy__' not in sys.builtin_module_names:
+ py.test.skip("pypy only test for no longdouble support")
+ BaseNumpyAppTest.setup_class.im_func(cls)
+
+ def test_nolongfloat(self):
+ import _numpypy
+ from _numpypy import dtype
+ assert not getattr(_numpypy, 'longdouble', False)
+ assert not getattr(_numpypy, 'float128', False)
+ assert not getattr(_numpypy, 'float96', False)
+ raises(TypeError, dtype, 'longdouble')
+ raises(TypeError, dtype, 'clongdouble')
+ raises(TypeError, dtype, 'longfloat')
+ raises(TypeError, dtype, 'clongfloat')
+ raises(TypeError, dtype, 'float128')
+ raises(TypeError, dtype, 'float96')
+
+class AppTestLongDoubleDtypes(BaseNumpyAppTest):
+ def setup_class(cls):
+ from pypy.module.micronumpy import Module
+ print dir(Module.interpleveldefs)
+ if not Module.interpleveldefs.get('longfloat', None):
+ py.test.skip('no longdouble types yet')
+ BaseNumpyAppTest.setup_class.im_func(cls)
+
+ def test_longfloat(self):
+ import _numpypy as numpy
+ # it can be float96 or float128
+ if numpy.longfloat != numpy.float64:
+ assert numpy.longfloat.mro()[1:] == [numpy.floating,
+ numpy.inexact, numpy.number,
+ numpy.generic, object]
+ a = numpy.array([1, 2, 3], numpy.longdouble)
+ assert type(a[1]) is numpy.longdouble
+ assert numpy.float64(12) == numpy.longdouble(12)
+ assert numpy.float64(12) == numpy.longfloat(12)
+ raises(ValueError, numpy.longfloat, '23.2df')
+
+
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit