[pypy-commit] pypy object-dtype2: add upstream compatible logic to allow True for 'foo' != np.arange(3)[1] in a shorcut hack
mattip
noreply at buildbot.pypy.org
Thu Apr 23 09:57:21 CEST 2015
Author: mattip <matti.picus at gmail.com>
Branch: object-dtype2
Changeset: r76898:cbba3abb9864
Date: 2015-04-23 10:52 +0300
http://bitbucket.org/pypy/pypy/changeset/cbba3abb9864/
Log: add upstream compatible logic to allow True for 'foo' !=
np.arange(3)[1] in a shorcut hack
diff --git a/pypy/module/micronumpy/test/test_object_arrays.py b/pypy/module/micronumpy/test/test_object_arrays.py
--- a/pypy/module/micronumpy/test/test_object_arrays.py
+++ b/pypy/module/micronumpy/test/test_object_arrays.py
@@ -37,6 +37,11 @@
assert (b == a).all()
c = np.array([1, 2, 3])
assert (a[0] != c[0])
+ assert (c[0] != a[0])
+ assert (a[0] > c[0])
+ assert (not a[0] < c[0])
+ assert (c[0] < a[0])
+ assert (not c[0] > a[0])
def test_logical_ufunc(self):
import numpy as np
diff --git a/pypy/module/micronumpy/ufuncs.py b/pypy/module/micronumpy/ufuncs.py
--- a/pypy/module/micronumpy/ufuncs.py
+++ b/pypy/module/micronumpy/ufuncs.py
@@ -441,8 +441,15 @@
elif w_ldtype.is_str() and w_rdtype.is_str() and \
self.comparison_func:
pass
- elif (w_ldtype.is_str() or w_rdtype.is_str()) and \
+ elif (w_ldtype.is_str()) and \
self.comparison_func and w_out is None:
+ if self.name in ('equal', 'less_equal', 'less'):
+ return space.wrap(False)
+ return space.wrap(True)
+ elif (w_rdtype.is_str()) and \
+ self.comparison_func and w_out is None:
+ if self.name in ('not_equal','less', 'less_equal'):
+ return space.wrap(True)
return space.wrap(False)
elif w_ldtype.is_flexible() or w_rdtype.is_flexible():
if self.comparison_func:
More information about the pypy-commit
mailing list