Author: mattip <[email protected]>
Branch:
Changeset: r72434:26c78d4a4421
Date: 2014-07-14 23:25 +0300
http://bitbucket.org/pypy/pypy/changeset/26c78d4a4421/
Log: fix dtype hash - fields can be dicts or {} or None
diff --git a/pypy/module/micronumpy/descriptor.py
b/pypy/module/micronumpy/descriptor.py
--- a/pypy/module/micronumpy/descriptor.py
+++ b/pypy/module/micronumpy/descriptor.py
@@ -73,7 +73,7 @@
self.base = subdtype.base
def __repr__(self):
- if self.fields is not None:
+ if self.fields:
return '<DType %r>' % self.fields
return '<DType %r>' % self.itemtype
@@ -256,7 +256,7 @@
def _compute_hash(self, space, x):
from rpython.rlib.rarithmetic import intmask
- if self.fields is None and self.subdtype is None:
+ if not self.fields and self.subdtype is None:
endian = self.byteorder
if endian == NPY.NATIVE:
endian = NPY.NATBYTE
@@ -269,7 +269,7 @@
if self.is_flexible():
y = intmask((1000003 * y) ^ self.alignment)
return intmask((1000003 * x) ^ y)
- if self.fields is not None:
+ if self.fields:
for name, (offset, subdtype) in self.fields.iteritems():
assert isinstance(subdtype, W_Dtype)
y = intmask(1000003 * (0x345678 ^ compute_hash(name)))
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
@@ -428,6 +428,8 @@
for t in [np.int_, np.float_]:
dt = np.dtype(t)
dt1 = dt.newbyteorder().newbyteorder()
+ assert dt.isbuiltin
+ assert not dt1.isbuiltin
dt2 = dt.newbyteorder("<")
dt3 = dt.newbyteorder(">")
assert dt.byteorder != dt1.byteorder
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit