[pypy-commit] pypy default: Fix dtype.__eq__
alex_gaynor
noreply at buildbot.pypy.org
Thu Jan 26 21:13:32 CET 2012
Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch:
Changeset: r51813:0e63f32cf93c
Date: 2012-01-26 15:13 -0500
http://bitbucket.org/pypy/pypy/changeset/0e63f32cf93c/
Log: Fix dtype.__eq__
diff --git a/pypy/module/micronumpy/interp_dtype.py b/pypy/module/micronumpy/interp_dtype.py
--- a/pypy/module/micronumpy/interp_dtype.py
+++ b/pypy/module/micronumpy/interp_dtype.py
@@ -90,11 +90,8 @@
return space.newtuple([])
def eq(self, space, w_other):
- if space.is_w(self, w_other):
- return True
- if space.isinstance_w(w_other, space.w_str):
- return self.name == space.str_w(w_other)
- return False
+ w_other = space.call_function(space.gettypefor(W_Dtype), w_other)
+ return space.is_w(self, w_other)
def descr_eq(self, space, w_other):
return space.wrap(self.eq(space, w_other))
diff --git a/pypy/module/micronumpy/test/test_dtypes.py b/pypy/module/micronumpy/test/test_dtypes.py
--- a/pypy/module/micronumpy/test/test_dtypes.py
+++ b/pypy/module/micronumpy/test/test_dtypes.py
@@ -9,13 +9,18 @@
assert d.num == 0
assert d.kind == 'b'
assert dtype('int8').num == 1
- assert dtype('int8') == 'int8'
- assert 'int8' == dtype('int8')
- assert dtype('int8') != 3
assert dtype(d) is d
assert dtype(None) is dtype(float)
raises(TypeError, dtype, 1042)
+ def test_dtype_eq(self):
+ from _numpypy import dtype
+
+ assert dtype("int8") == "int8"
+ assert "int8" == dtype("int8")
+ raises(TypeError, lambda: dtype("int8") == 3)
+ assert dtype(bool) == bool
+
def test_dtype_with_types(self):
from _numpypy import dtype
More information about the pypy-commit
mailing list