Author: mattip <[email protected]>
Branch: missing-ndarray-attributes
Changeset: r60298:317b0a0672b2
Date: 2013-01-21 18:03 +0200
http://bitbucket.org/pypy/pypy/changeset/317b0a0672b2/

Log:    implement complex astype, complex compress

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
@@ -134,6 +134,11 @@
     def box(self, value):
         return self.BoxType(rffi.cast(self.T, value))
 
+    @specialize.argtype(1, 2)
+    def box_complex(self, real, imag):
+        #XXX this is the place to display a warning
+        return self.BoxType(rffi.cast(self.T, real))
+
     def unbox(self, box):
         assert isinstance(box, self.BoxType)
         return box.value
@@ -319,6 +324,16 @@
         else:
             return self.False
 
+    @specialize.argtype(1, 2)
+    def box_complex(self, real, imag):
+        box = Primitive.box(self, real)
+        if box.value:
+            return self.True
+        box = Primitive.box(self, imag)
+        if box.value:
+            return self.True
+        return self.False
+
     def coerce_subtype(self, space, w_subtype, w_item):
         # Doesn't return subclasses so it can return the constants.
         return self._coerce(space, w_item)
@@ -1050,6 +1065,10 @@
     def for_computation(self, v):   
         return float(v[0]), float(v[1])
 
+    def read_bool(self, arr, i, offset):
+        v = self.for_computation(self._read(arr.storage, i, offset))
+        return bool(v[0]) or bool(v[1])
+
     def get_element_size(self):
         return 2 * rffi.sizeof(self._COMPONENTS_T)
 
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to