Author: mattip <[email protected]>
Branch: numpypy.float16
Changeset: r58798:2d7ca9c26e59
Date: 2012-11-08 14:34 -0800
http://bitbucket.org/pypy/pypy/changeset/2d7ca9c26e59/
Log: translation fix
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
@@ -142,7 +142,9 @@
tests.extend([('b','I','l'), ('b','L','d'), ('h','I','l'),
('h','L','d'), ('i','I','l'), ('i','L','d')])
for d1, d2, dout in tests:
- assert (array([1], d1) + array([1], d2)).dtype is dtype(dout)
+ # make a failed test print helpful info
+ d3 = (array([1], d1) + array([1], d2)).dtype
+ assert (d1, d2, repr(d3)) == (d1, d2, repr(dtype(dout)))
def test_add_int8(self):
from _numpypy import array, dtype
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
@@ -10,10 +10,11 @@
from pypy.rlib.rawstorage import (alloc_raw_storage, raw_storage_setitem,
raw_storage_getitem)
from pypy.rlib.objectmodel import specialize
-from pypy.rlib.rarithmetic import widen, byteswap, intmask
+from pypy.rlib.rarithmetic import widen, byteswap, r_ulonglong
from pypy.rpython.lltypesystem import lltype, rffi
from pypy.rlib.rstruct.runpack import runpack
-from pypy.rlib.rstruct.ieee import float_pack, float_unpack
+from pypy.rlib.rstruct.nativefmttable import native_is_bigendian
+from pypy.rlib.rstruct.ieee import float_pack, float_unpack, unpack_float
from pypy.tool.sourcetools import func_with_new_name
from pypy.rlib import jit
from pypy.rlib.rstring import StringBuilder
@@ -920,8 +921,9 @@
return rffi.sizeof(self._STORAGE_T)
def runpack_str(self, s):
- hbits = int(runpack('H', s))
- return self.box(float_unpack(hbits, 2))
+ assert len(s) == 2
+ fval = unpack_float(s, native_is_bigendian)
+ return self.box(fval)
def for_computation(self, v):
return float(v)
@@ -930,8 +932,8 @@
return self.box(-1.0)
def _read(self, storage, i, offset):
- hbits = intmask(raw_storage_getitem(self._STORAGE_T, storage, i +
offset))
- return float_unpack(hbits, 2)
+ hbits = raw_storage_getitem(self._STORAGE_T, storage, i + offset)
+ return float_unpack(r_ulonglong(hbits), 2)
def _write(self, storage, i, offset, value):
hbits = float_pack(value,2)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit