[pypy-commit] pypy default: fix for failing test
mattip
noreply at buildbot.pypy.org
Thu Oct 11 09:35:06 CEST 2012
Author: mattip <matti.picus at gmail.com>
Branch:
Changeset: r58005:a7f5a71b05d1
Date: 2012-10-11 07:36 +0200
http://bitbucket.org/pypy/pypy/changeset/a7f5a71b05d1/
Log: fix for failing test
diff --git a/pypy/module/micronumpy/interp_ufuncs.py b/pypy/module/micronumpy/interp_ufuncs.py
--- a/pypy/module/micronumpy/interp_ufuncs.py
+++ b/pypy/module/micronumpy/interp_ufuncs.py
@@ -17,15 +17,18 @@
return not dtype.itemtype.bool(val)
class W_Ufunc(Wrappable):
- _attrs_ = ["name", "promote_to_float", "promote_bools", "identity", "allow_complex"]
- _immutable_fields_ = ["promote_to_float", "promote_bools", "name", "allow_complex"]
+ _attrs_ = ["name", "promote_to_float", "promote_bools", "identity",
+ "allow_complex", "complex_to_float"]
+ _immutable_fields_ = ["promote_to_float", "promote_bools", "name",
+ "allow_complex", "complex_to_float"]
def __init__(self, name, promote_to_float, promote_bools, identity,
- int_only, allow_complex):
+ int_only, allow_complex, complex_to_float):
self.name = name
self.promote_to_float = promote_to_float
self.promote_bools = promote_bools
self.allow_complex = allow_complex
+ self.complex_to_float = complex_to_float
self.identity = identity
self.int_only = int_only
@@ -216,10 +219,11 @@
_immutable_fields_ = ["func", "name"]
def __init__(self, func, name, promote_to_float=False, promote_bools=False,
- identity=None, bool_result=False, int_only=False, allow_complex=True):
+ identity=None, bool_result=False, int_only=False,
+ allow_complex=True, complex_to_float=False):
W_Ufunc.__init__(self, name, promote_to_float, promote_bools, identity,
- int_only, allow_complex)
+ int_only, allow_complex, complex_to_float)
self.func = func
self.bool_result = bool_result
@@ -248,6 +252,11 @@
res_dtype = interp_dtype.get_dtype_cache(space).w_booldtype
else:
res_dtype = calc_dtype
+ if self.complex_to_float and calc_dtype.is_complex_type():
+ if calc_dtype.name == 'complex64':
+ res_dtype = interp_dtype.get_dtype_cache(space).w_float32dtype
+ else:
+ res_dtype = interp_dtype.get_dtype_cache(space).w_float64dtype
if w_obj.is_scalar():
w_val = self.func(calc_dtype,
w_obj.get_scalar_value().convert_to(calc_dtype))
@@ -269,10 +278,11 @@
argcount = 2
def __init__(self, func, name, promote_to_float=False, promote_bools=False,
- identity=None, comparison_func=False, int_only=False, allow_complex=True):
+ identity=None, comparison_func=False, int_only=False,
+ allow_complex=True, complex_to_float=False):
W_Ufunc.__init__(self, name, promote_to_float, promote_bools, identity,
- int_only, allow_complex)
+ int_only, allow_complex, complex_to_float)
self.func = func
self.comparison_func = comparison_func
if name == 'logical_and':
@@ -534,14 +544,14 @@
("positive", "pos", 1),
("negative", "neg", 1),
- ("absolute", "abs", 1),
+ ("absolute", "abs", 1, {"complex_to_float": True}),
("sign", "sign", 1, {"promote_bools": True}),
("signbit", "signbit", 1, {"bool_result": True,
"allow_complex": False}),
("reciprocal", "reciprocal", 1),
("conjugate", "conj", 1),
- ("real", "real", 1),
- ("imag", "imag", 1),
+ ("real", "real", 1, {"complex_to_float": True}),
+ ("imag", "imag", 1, {"complex_to_float": True}),
("fabs", "fabs", 1, {"promote_to_float": True,
"allow_complex": False}),
More information about the pypy-commit
mailing list