Author: Matti Picus <[email protected]>
Branch:
Changeset: r67350:413f957cdd2b
Date: 2013-10-13 23:53 +0300
http://bitbucket.org/pypy/pypy/changeset/413f957cdd2b/
Log: allow comparison between ndarray and string
diff --git a/pypy/module/micronumpy/interp_numarray.py
b/pypy/module/micronumpy/interp_numarray.py
--- a/pypy/module/micronumpy/interp_numarray.py
+++ b/pypy/module/micronumpy/interp_numarray.py
@@ -954,6 +954,13 @@
def descr___array_finalize__(self, space, w_obj):
pass
+ def descr___array_wrap__(self, space, w_obj, w_context=None):
+ return w_obj
+
+ def descr___array_prepare__(self, space, w_obj, w_context=None):
+ return w_obj
+ pass
+
@unwrap_spec(offset=int, order=str)
def descr_new_array(space, w_subtype, w_shape, w_dtype=None, w_buffer=None,
offset=0, w_strides=None, order='C'):
@@ -1144,7 +1151,8 @@
__reduce__ = interp2app(W_NDimArray.descr_reduce),
__setstate__ = interp2app(W_NDimArray.descr_setstate),
__array_finalize__ = interp2app(W_NDimArray.descr___array_finalize__),
-
+ __array_prepare__ = interp2app(W_NDimArray.descr___array_prepare__),
+ __array_wrap__ = interp2app(W_NDimArray.descr___array_wrap__),
__array__ = interp2app(W_NDimArray.descr___array__),
)
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
@@ -342,6 +342,9 @@
if w_ldtype.is_str_type() and w_rdtype.is_str_type() and \
self.comparison_func:
pass
+ elif (w_ldtype.is_str_type() or w_rdtype.is_str_type()) and \
+ self.comparison_func and w_out is None:
+ return space.wrap(False)
elif (w_ldtype.is_flexible_type() or \
w_rdtype.is_flexible_type()):
raise OperationError(space.w_TypeError, space.wrap(
diff --git a/pypy/module/micronumpy/test/test_ufuncs.py
b/pypy/module/micronumpy/test/test_ufuncs.py
--- a/pypy/module/micronumpy/test/test_ufuncs.py
+++ b/pypy/module/micronumpy/test/test_ufuncs.py
@@ -712,7 +712,8 @@
def test_comparisons(self):
import operator
- from numpypy import equal, not_equal, less, less_equal, greater,
greater_equal
+ from numpypy import (equal, not_equal, less, less_equal, greater,
+ greater_equal, arange)
for ufunc, func in [
(equal, operator.eq),
@@ -735,7 +736,9 @@
(3, 3.5),
]:
assert ufunc(a, b) == func(a, b)
-
+ c = arange(10)
+ val = c == 'abcdefg'
+ assert val == False
def test_count_nonzero(self):
from numpypy import count_nonzero
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit