Matti Picus avatar Matti Picus committed a626fbc

pass byteswap tests

Comments (0)

Files changed (1)

pypy/module/micronumpy/types.py

         raw_storage_setitem(storage, i + offset,
                 rffi.cast(self._STORAGE_T, hbits))
 
+    def byteswap(self, w_v):
+        value = self.unbox(w_v)
+        hbits = float_pack(value,2)
+        swapped = byteswap(rffi.cast(self._STORAGE_T, hbits))
+        return self.box(float_unpack(r_ulonglong(swapped), 2))
+
 class NonNativeFloat16(Float16):
     _attrs_ = ()
     BoxType = interp_boxes.W_Float16Box
     def get_element_size(self):
         return 2 * rffi.sizeof(self._COMPONENTS_T)
 
+    def byteswap(self, w_v):
+        real, imag = self.unbox(w_v)
+        return self.box_complex(byteswap(real), byteswap(imag))
+
     @specialize.argtype(1)
     def box(self, value):
         return self.BoxType(
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.