[pypy-commit] pypy missing-ndarray-attributes: fix merge, add failing byteswap tests for new dtypes, partial implementations
mattip
noreply at buildbot.pypy.org
Thu Dec 27 22:58:12 CET 2012
Author: mattip <matti.picus at gmail.com>
Branch: missing-ndarray-attributes
Changeset: r59592:fe6cb9eff6f5
Date: 2012-12-27 23:57 +0200
http://bitbucket.org/pypy/pypy/changeset/fe6cb9eff6f5/
Log: fix merge, add failing byteswap tests for new dtypes, partial
implementations
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
@@ -738,6 +738,15 @@
a = array([1, 2, 3], dtype=self.non_native_prefix + 'f4')
assert a[0] == 1
assert (a + a)[1] == 4
+ a = array([1, 2, 3], dtype=self.non_native_prefix + 'f2')
+ assert a[0] == 1
+ assert (a + a)[1] == 4
+ a = array([1, 2, 3], dtype=self.non_native_prefix + 'g') # longdouble
+ assert a[0] == 1
+ assert (a + a)[1] == 4
+ a = array([1, 2, 3], dtype=self.non_native_prefix + 'G') # clongdouble
+ assert a[0] == 1
+ assert (a + a)[1] == 4
class AppTestPyPyOnly(BaseNumpyAppTest):
def setup_class(cls):
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
@@ -1598,6 +1598,7 @@
assert (a == [1, 256 + 2, 3]).all()
assert (a.byteswap(True) == [0x0100, 0x0201, 0x0300]).all()
assert (a == [0x0100, 0x0201, 0x0300]).all()
+ assert False, 'test float, float16, complex byteswap'
def test_clip(self):
from _numpypy import array
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
@@ -936,9 +936,6 @@
swapped_value = byteswap(rffi.cast(self.T, value))
raw_storage_setitem(storage, i + offset, swapped_value)
- def pack_str(self, box):
- return struct.pack(self.format_code, byteswap(self.unbox(box)))
-
class Float16(BaseType, Float):
_attrs_ = ()
_STORAGE_T = rffi.USHORT
@@ -974,13 +971,14 @@
BoxType = interp_boxes.W_Float16Box
def _read(self, storage, i, offset):
- res = Float16._read(self, storage, i, offset)
- #return byteswap(res) XXX
- return res
+ hbits = raw_storage_getitem(self._STORAGE_T, storage, i + offset)
+ return float_unpack(r_ulonglong(byteswap(hbits)), 2)
def _write(self, storage, i, offset, value):
- #value = byteswap(value) XXX
- Float16._write(self, storage, i, offset, value)
+ hbits = float_pack(value,2)
+ raw_storage_setitem(storage, i + offset,
+ byteswap(rffi.cast(self._STORAGE_T, hbits)))
+
class Float32(BaseType, Float):
_attrs_ = ()
More information about the pypy-commit
mailing list