[pypy-commit] pypy default: fix dtype field access case
bdkearns
noreply at buildbot.pypy.org
Mon Feb 24 12:43:23 CET 2014
Author: Brian Kearns <bdkearns at gmail.com>
Branch:
Changeset: r69352:a703a516c204
Date: 2014-02-24 06:42 -0500
http://bitbucket.org/pypy/pypy/changeset/a703a516c204/
Log: fix dtype field access case
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
@@ -289,7 +289,7 @@
return space.w_False
def descr_getitem(self, space, w_item):
- if self.fields is None:
+ if not self.fields:
raise OperationError(space.w_KeyError, space.wrap(
"There are no fields in dtype %s." % self.name))
if space.isinstance_w(w_item, space.w_basestring):
@@ -311,7 +311,7 @@
"Field named '%s' not found." % item))
def descr_len(self, space):
- if self.fields is None:
+ if not self.fields:
return space.wrap(0)
return space.wrap(len(self.fields))
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
@@ -65,13 +65,10 @@
assert dtype(None) is dtype(float)
- e = dtype('int8')
- exc = raises(KeyError, "e[2]")
- assert exc.value.message == "There are no fields in dtype int8."
- exc = raises(KeyError, "e['z']")
- assert exc.value.message == "There are no fields in dtype int8."
- exc = raises(KeyError, "e[None]")
- assert exc.value.message == "There are no fields in dtype int8."
+ for d in [dtype('<c8'), dtype('>i4')]:
+ for key in ["d[2]", "d['z']", "d[None]"]:
+ exc = raises(KeyError, key)
+ assert exc.value[0] == "There are no fields in dtype %s." % str(d)
exc = raises(TypeError, dtype, (1, 2))
assert exc.value[0] == 'data type not understood'
diff --git a/pypy/module/micronumpy/types.py b/pypy/module/micronumpy/types.py
--- a/pypy/module/micronumpy/types.py
+++ b/pypy/module/micronumpy/types.py
@@ -118,14 +118,12 @@
def __init__(self, native=True):
self.native = native
- def _unimplemented_ufunc(self, *args):
- raise NotImplementedError
+ def __repr__(self):
+ return self.__class__.__name__
def malloc(self, size):
return alloc_raw_storage(size, track_allocation=False, zero=True)
- def __repr__(self):
- return self.__class__.__name__
class Primitive(object):
_mixin_ = True
More information about the pypy-commit
mailing list