Commits

mattip  committed 2d7ca9c

translation fix

  • Participants
  • Parent commits ac1d554
  • Branches numpypy.float16

Comments (0)

Files changed (2)

File pypy/module/micronumpy/test/test_dtypes.py

             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

File pypy/module/micronumpy/types.py

 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
         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)
         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)