[pypy-commit] pypy numpy-1.10: str(np.dtype('c')) == '|S1', but str(np.dtype('c8') == 'complex64'. Go figure
mattip
noreply at buildbot.pypy.org
Wed Nov 11 14:47:09 EST 2015
Author: mattip <matti.picus at gmail.com>
Branch: numpy-1.10
Changeset: r80639:f3c95cf1784f
Date: 2015-11-09 19:34 +0200
http://bitbucket.org/pypy/pypy/changeset/f3c95cf1784f/
Log: str(np.dtype('c')) == '|S1', but str(np.dtype('c8') == 'complex64'.
Go figure
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
@@ -497,6 +497,8 @@
return self.descr_get_name(space)
def descr_repr(self, space):
+ if isinstance(self.itemtype, types.CharType):
+ return space.wrap("dtype('S1')")
if self.fields:
r = self.descr_get_descr(space, style='repr')
elif self.subdtype is not None:
@@ -1122,7 +1124,7 @@
size = int(name[1:])
except ValueError:
raise oefmt(space.w_TypeError, "data type not understood")
- if char == NPY.CHARLTR:
+ if char == NPY.CHARLTR and size == 0:
return W_Dtype(
types.CharType(space),
elsize=1,
@@ -1133,7 +1135,7 @@
return new_unicode_dtype(space, size)
elif char == NPY.VOIDLTR:
return new_void_dtype(space, size)
- assert False
+ raise oefmt(space.w_TypeError, 'data type "%s" not understood', name)
def new_string_dtype(space, size):
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
@@ -1056,6 +1056,7 @@
assert d.char == 'c'
assert d.kind == 'S'
assert d.str == '|S1'
+ assert repr(d) == "dtype('S1')"
class AppTestRecordDtypes(BaseNumpyAppTest):
spaceconfig = dict(usemodules=["micronumpy", "struct", "binascii"])
More information about the pypy-commit
mailing list