[pypy-commit] pypy numpy-dtype-refactor-complex: progress, can now see if 2 complexes are equal and read them out of a value
alex_gaynor
noreply at buildbot.pypy.org
Mon Dec 5 01:38:03 CET 2011
Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: numpy-dtype-refactor-complex
Changeset: r50159:2d7dd6a415a4
Date: 2011-12-04 19:37 -0500
http://bitbucket.org/pypy/pypy/changeset/2d7dd6a415a4/
Log: progress, can now see if 2 complexes are equal and read them out of
a value
diff --git a/pypy/module/micronumpy/interp_boxes.py b/pypy/module/micronumpy/interp_boxes.py
--- a/pypy/module/micronumpy/interp_boxes.py
+++ b/pypy/module/micronumpy/interp_boxes.py
@@ -164,6 +164,11 @@
class W_Complex128Box(W_ComplexFloatingBox, CompositeBox):
descr__new__, get_dtype = new_dtype_getter("complex128")
+ def convert_to(self, dtype):
+ if dtype.itemtype.is_correct_box(self):
+ return self
+ raise NotImplementedError
+
W_GenericBox.typedef = TypeDef("generic",
__module__ = "numpypy",
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
@@ -52,6 +52,9 @@
# exp = sin = cos = tan = arcsin = arccos = arctan = arcsinh = \
# arctanh = _unimplemented_ufunc
+ def is_correct_box(self, box):
+ return isinstance(box, self.BoxType)
+
class Primitive(object):
_mixin_ = True
def get_element_size(self):
@@ -432,4 +435,14 @@
if isinstance(w_item, self.BoxType):
return w_item
real, imag = space.unpackcomplex(w_item)
- return self.box([self.real.box(real), self.imag.box(imag)])
\ No newline at end of file
+ return self.box([self.real.box(real), self.imag.box(imag)])
+
+ def for_computation(self, (real, imag)):
+ return [
+ self.real.for_computation(self.real.unbox(real)),
+ self.imag.for_computation(self.imag.unbox(imag)),
+ ]
+
+ @raw_binary_op
+ def eq(self, (real1, imag1), (real2, imag2)):
+ return real1 == real2 and imag1 == imag2
More information about the pypy-commit
mailing list